2016-02-01 36 views
0

在我们公司,我们将Maven添加到项目比从未有过,但我们需要我们的项目使用动态Web模块2.5方面,因为我们将部署它一个Tomcat 6服务器,我们不允许用Tomcat 7服务器替换它。无法将动态Web模块方面从3.0更改为2.5

我可以手动将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

下面是pom.xml中 –

+1

[编辑] pom.yml文件到的主要问题,那么我们就可以为什么,为什么,你使用'Maven的Eclipse的plugin'帮助你 – Ferrybig

+0

?删除它并安装M2Eclipse。 – Tunaki

回答

0

我想我已经解决了这个问题。

我刚刚设置以下标记为“Maven的战争插件”的配置:

<warSourceDirectory>WebContent</warSourceDirectory> 
<webappDirectory>WebContent</webappDirectory> 

默认情况下,Maven的是找对的src/main/webapp的web.xml文件,但它不存在,这是对的WebContent/WEB-INF

感谢您的答复。