我试图让我的Tomcat服务器提供文件。我做了一个非常简单的例子,告诉你什么是错的,即使它很简单,它也不起作用。Tomcat未从maven-war-plugin提供文件
我的项目是由这样的:
test
|->assets
| |->testB.txt
|->src
| |->main
| | |->webapp
| | | |->WEB-INF
| | | | |->web.xml
| | | |->testA.txt
|-> pom.xml
的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<directory>assets/</directory>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
</web-app>
如果我执行mvn package tomcat6:run
,我可以访问testA.txt
但我无法访问testB.txt
,就算了,当我有一个看一个的“的.war”产生的,我看到:
|->testA.txt
|->testB.txt
|->META-INF
|->WEB-INF
| |->web.xml
| |->classes
我想不通为什么我要一个访问,但我能看不到其他的(404错误)...
感谢您的解释。我没有意识到这一点。现在它工作得很好。 – Utundu