有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法将动态Web模块方面从3.0更改为2.5

在我们公司,我们将Maven添加到一个项目中,但我们需要我们的项目使用Dynamic Web Module 2.5方面,因为我们将在Tomcat 6服务器上部署它,不允许用Tomcat 7服务器替换它

我可以手动将Facet设置为2.5,但问题是,当我使用Maven工具在Eclipse上更新项目时,它会自动将其更改为3.0

我尝试了几十种解决方案,比如改变网络。xml头,更改方面并按特定顺序更新项目,向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>

这里是网络。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">

这里是组织。日食wst。常见的项目方面果心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>

谢谢大家的回复


共 (1) 个答案

  1. # 1 楼答案

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

    我刚刚将以下标签设置为“maven war插件”配置:

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

    默认情况下,Maven正在寻找网络。src/main/webapp上的xml文件,但它不在那里,而是在WebContent/WEB-INF上

    谢谢你的回复