我正在使用Maven3,并且我正在尝试在webapp文件夹下添加META-INF文件夹。所以我试着做以下几件事:
src
main
webapp
META-INF
context.xml
WEB-INF
下面是我的POM文件:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.data</groupId>
<artifactId>Java-WebApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Java-Web Application</name>
<!-- Shared version number properties-->
<properties>
<org.springframework.version>3.0.6.RELEASE</org.springframework.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>data</finalName>
</build>
<parent>
<groupId>com.data</groupId>
<artifactId>Java-Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
</project>
在src/main/resources下,我添加了一个META-INF\context.xml。当使用mvn包打包WAR文件时,结构如下所示:
data
webapp
META-INF
WEB-INF
index.jsp
可以看到WEB-INF下的相关文件。但是,META-INF文件夹为空。我的默认Maven将在WEB-INF/classes下添加资源。
我特别想要有:
data
webapp
META-INF
context.xml
WEB-INF
这怎麽可能?我试过其他方法,但还是不起作用。context.xml包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/data1"/>
我已经尝试从src\main\resources中删除META-INF文件夹,并将其直接放在webapp\META-INF下。将显示context.xml,但当将其部署到Tomcat中时,我定义的上下文根不起作用。
发布于 2012-12-04 19:24:49
将META-INF文件夹放在src/main/resources中。
把这个放到你的pom.xml上。抱歉,我之前错过了;
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>${project.basedir}/src/main/resources
</directory>
</resource>
</webResources>
<warName>mywar</warName>
</configuration>
</plugin>
</plugins>
</build>
web资源标签才是最重要的……希望这能有所帮助
发布于 2015-08-26 23:06:24
请改用标签。上面的答案使用using将src/main/resources中的所有内容复制到web应用程序的根目录,这可能不是您想要做的事情,也不是您想要遵循的示例。
https://stackoverflow.com/questions/13701300
复制相似问题