在我们公司,我们将Maven添加到项目中从未有过,但我们需要我们的项目使用Dynamic Web Module 2.5 Facet,因为我们将它部署在Tomcat 6 Server上,我们不允许更换它与Tomcat 7服务器。
我可以手动将Facet设置为2.5,但事实是,当我使用Maven工具在Eclipse上更新项目时,它会自动将其更改为3.0。
我已尝试过几十个解决方案,例如更改web.xml标头,更改Facets并按特定顺序更新项目,向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>Stofi</groupId>
<artifactId>Stofi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<src.dir>src</src.dir>
<basedir></basedir>
</properties>
<build>
<directory>${project.basedir}/target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>${project.artifactId}</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>${src.dir}</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/Idiomas</directory>
<!-- <excludes> -->
<!-- <exclude>**/*.properties</exclude> -->
<!-- </excludes> -->
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<version>3.1</version>
<excludes>
<exclude>src/Idiomas</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.10</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>WebContent</webappDirectory>
<packagingExcludes>src\Idiomas</packagingExcludes>
<packagingExcludes>WEB-INF\classes\*.properties</packagingExcludes>
<packagingExcludes>WEB-INF\classes\**\*.java</packagingExcludes>
<!-- <outputDirectory>C:\Desarrollo\ServersPruebas\tomcat_stofi\webapps</outputDirectory> -->
<webResources>
<resource>
<targetPath>WEB-INF\classes\Idiomas\</targetPath>
<filtering>false</filtering>
<directory>src\Idiomas</directory>
<includes>
<include>**\*.*</include>
</includes>
<excludes>
<exclude>**\*.git</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.1.6.RELEASE</version>
<scope>test</scope>
</dependency> -->
<!-- LOCAL LIBRARIES -->
</dependencies>
<packaging>war</packaging>
</project>
这是WEB.XML标题
<web-app 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" version="2.5">
这是org.eclipse.wst.common.project.facet.core.xml
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="jst.java"/>
<installed facet="jst.java" version="1.6"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.web" version="2.5"/>
</faceted-project>
谢谢大家的回复。
答案 0 :(得分:0)
我想我已经解决了这个问题。
我只是将以下标记设置为&#39; maven-war-plugin&#39;配置:
<warSourceDirectory>WebContent</warSourceDirectory>
<webappDirectory>WebContent</webappDirectory>
默认情况下,Maven在src / main / webapp上寻找web.xml文件,但它不在那里,它在WebContent / WEB-INF上
感谢您的所有回复。