Maven Java EE配置 [英] Maven Java EE Configuration

查看:90
本文介绍了Maven Java EE配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <?xml version =1.0?> 
< project xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdxmlns = http://maven.apache.org/POM/4.0.0
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance>
< modelVersion> 4.0.0< / modelVersion>
< groupId> spring< / groupId>
< artifactId>示例< / artifactId>
< version> 0.0.1-SNAPSHOT< / version>
< packaging> war< / packaging>
< name> example< / name>
< url> http://maven.apache.org< / url>
<属性>
< project.build.sourceEncoding> UTF-8< /project.build.sourceEncoding>
< / properties>
<依赖关系>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-context< / artifactId>
< version> 4.0.3.RELEASE< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> org.springframework.ws< / groupId>
< artifactId> spring-ws-core< / artifactId>
< version> 2.1.4.RELEASE< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> org.springframework.security< / groupId>
< artifactId> spring-security-web< / artifactId>
< version> 3.2.3.RELEASE< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> org.springframework.security< / groupId>
< artifactId> spring-security-config< / artifactId>
< version> 3.2.3.RELEASE< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-core< / artifactId>
< version> 4.3.5.Final< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-validator< / artifactId>
< version> 5.1.0.Final< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-orm< / artifactId>
< version> 4.0.3.RELEASE< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-tx< / artifactId>
< version> 4.0.3.RELEASE< / version>
< scope> compile< / scope>
< / dependency>
< / dependencies>
< repositories>
< repository>
< snapshots>
< enabled> false< / enabled>
< / snapshots>
< id> central< / id>
< name> Central Repository< / name>
< url> http://repo.maven.apache.org/maven2< / url>
< / repository>
< / repositories>
< pluginRepositories>
< pluginRepository>
< releases>
< updatePolicy>从不< / updatePolicy>
< / releases>
< snapshots>
< enabled> false< / enabled>
< / snapshots>
< id> central< / id>
< name> Central Repository< / name>
< url> http://repo.maven.apache.org/maven2< / url>
< / pluginRepository>
< / pluginRepositories>
< build>
< sourceDirectory> C:\Users\Kleber\Downloads\Projetos\example\src\main\java< / sourceDirectory>
< scriptSourceDirectory> C:\Users\Kleber\Downloads\Projetos\example\src\main\scripts< / scriptSourceDirectory>
< testSourceDirectory> C:\Users\Kleber\Downloads\Projetos\example\src\test\java< / testSourceDirectory>
< outputDirectory> C:\Users\Kleber\Downloads\Projetos\example\target\classes< / outputDirectory>
< testOutputDirectory> C:\Users\Kleber\Downloads\Projetos\example\target\test-classes< / testOutputDirectory>
< resources>
< resource>
< directory> C:\Users\Kleber\Downloads\Projetos\example\src\main\resources< / directory>
< / resource>
< / resources>
< testResources>
< testResource>
< directory> C:\Users\Kleber\Downloads\Projetos\example\src\test\resources< / directory>
< / testResource>
< / testResources>
< directory> C:\Users\Kleber\Downloads\Projetos\example\target< / directory>
< finalName> example-0.0.1-SNAPSHOT< / finalName>
< pluginManagement>
< plugins>
< plugin>
< artifactId> maven-antrun-plugin< / artifactId>
< version> 1.3< / version>
< / plugin>
< plugin>
< artifactId> maven-assembly-plugin< / artifactId>
< version> 2.2-beta-5< / version>
< / plugin>
< plugin>
< artifactId> maven-dependency-plugin< / artifactId>
< version> 2.1< / version>
< / plugin>
< plugin>
< artifactId> maven-release-plugin< / artifactId>
< version> 2.0< / version>
< / plugin>
< / plugins>
< / pluginManagement>
< plugins>
< plugin>
< groupId> org.apache.tomcat.maven< / groupId>
< artifactId> tomcat7-maven-plugin< / artifactId>
< version> 2.2< / version>
< configuration>
< url> http:// localhost:8080 / manager / text< / url>
< server> TomcatServer< / server>
< path> / webappExample< / path>
< username> user001< / username>
< password> 123< / password>
< / configuration>
< / plugin>
< plugin>
< artifactId> maven-clean-plugin< / artifactId>
< version> 2.4.1< / version>
<执行>
< execution>
< id> default-clean< / id>
< phase> clean< / phase>
< goals>
< goal> clean< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< plugin>
< artifactId> maven-install-plugin< / artifactId>
< version> 2.3.1< / version>
<执行>
< execution>
< id> default-install< / id>
< phase> install< / phase>
< goals>
< goal> install< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< plugin>
< artifactId> maven-resources-plugin< / artifactId>
< version> 2.5< / version>
<执行>
< execution>
< id> default-resources< / id>
< phase> process-resources< / phase>
< goals>
< goal> resources< / goal>
< / goals>
< / execution>
< execution>
< id> default-testResources< / id>
< phase> process-test-resources< / phase>
< goals>
< goal> testResources< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< plugin>
< artifactId> maven-surefire-plugin< / artifactId>
< version> 2.10< / version>
<执行>
< execution>
< id> default-test< / id>
< phase> test< / phase>
< goals>
< goal> test< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< plugin>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 2.3.2< / version>
<执行>
< execution>
< id> default-testCompile< / id>
< phase> test-compile< / phase>
< goals>
< goal> testCompile< / goal>
< / goals>
< / execution>
< execution>
< id> default-compile< / id>
< phase> compile< / phase>
< goals>
< goal> compile< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< plugin>
< artifactId> maven-war-plugin< / artifactId>
< version> 2.1.1< / version>
<执行>
< execution>
< id> default-war< / id>
< phase> package< / phase>
< goals>
< goal> war< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< plugin>
< artifactId> maven-deploy-plugin< / artifactId>
< version> 2.7< / version>
<执行>
< execution>
< id> default-deploy< / id>
< phase> deploy< / phase>
< goals>
< goal> deploy< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< plugin>
< artifactId> maven-site-plugin< / artifactId>
< version> 3.0< / version>
<执行>
< execution>
< id> default-site< / id>
< phase> site< / phase>
< goals>
< goal> site< / goal>
< / goals>
< configuration>
< outputDirectory> C:\Users\Kleber\Downloads\Projetos\example\target\site< / outputDirectory>
< reportPlugins>
< reportPlugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-project-info-reports-plugin< / artifactId>
< / reportPlugin>
< / reportPlugins>
< / configuration>
< / execution>
< execution>
< id> default-deploy< / id>
< phase> site-deploy< / phase>
< goals>
< goal> deploy< / goal>
< / goals>
< configuration>
< outputDirectory> C:\Users\Kleber\Downloads\Projetos\example\target\site< / outputDirectory>
< reportPlugins>
< reportPlugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-project-info-reports-plugin< / artifactId>
< / reportPlugin>
< / reportPlugins>
< / configuration>
< / execution>
< / executions>
< configuration>
< outputDirectory> C:\Users\Kleber\Downloads\Projetos\example\target\site< / outputDirectory>
< reportPlugins>
< reportPlugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-project-info-reports-plugin< / artifactId>
< / reportPlugin>
< / reportPlugins>
< / configuration>
< / plugin>
< / plugins>
< / build>
< reporting>
< outputDirectory> C:\Users\Kleber\Downloads\Projetos\example\target\site< / outputDirectory>
< / reporting>
< / project>

在这一刻,我的Eclipse IDE上的标记选项卡中显示了这个错误: p>

 说明资源路径位置类型
动态Web模块3.0需要Java 1.6或更高版本。示例行1 Maven Java EE配置问题
一个或多个约束未满足。示例行1 Maven Java EE配置问题

我尝试在我的项目的Build路径中修复此配置(在属性/ Java构建路径中),但是当我运行Maven> Update Project时,此选项的值返回到上一个。



我应该将此选项更改为解决这个错误?

解决方案


  1. 转到项目 Build Path 并将Java库版本更改为 1.7

  2. 转到Eclipse首选项 - > Java - > Compilre - >更改合规性级别到 1.7


  3. 右键单击项目 - >属性 - >项目方面

  4. 取消选中动态Web模块,然后单击应用(也取消选中 JavaServer Faces 如果你这样做)

  5. Java facet版本更改为 1.7 并单击应用

  6. 添加 Dyanmic Web Module v3.0 ,应用程序LY。

Eclipse的facet配置是错误的。确保在检查和取消选择面之间保持应用



链接:

  • 不能将项目方面的动态Web模块版本更改为3.0?
  • 将项目方面动态Web模块的版本更改为2.5


    In my maven project, I have this Effective 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>spring</groupId>
      <artifactId>example</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>war</packaging>
      <name>example</name>
      <url>http://maven.apache.org</url>
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>
      <dependencies>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <version>4.0.3.RELEASE</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.ws</groupId>
          <artifactId>spring-ws-core</artifactId>
          <version>2.1.4.RELEASE</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.security</groupId>
          <artifactId>spring-security-web</artifactId>
          <version>3.2.3.RELEASE</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.security</groupId>
          <artifactId>spring-security-config</artifactId>
          <version>3.2.3.RELEASE</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-core</artifactId>
          <version>4.3.5.Final</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-validator</artifactId>
          <version>5.1.0.Final</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-orm</artifactId>
          <version>4.0.3.RELEASE</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-tx</artifactId>
          <version>4.0.3.RELEASE</version>
          <scope>compile</scope>
        </dependency>
      </dependencies>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>Central Repository</name>
          <url>http://repo.maven.apache.org/maven2</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <releases>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>Central Repository</name>
          <url>http://repo.maven.apache.org/maven2</url>
        </pluginRepository>
      </pluginRepositories>
      <build>
        <sourceDirectory>C:\Users\Kleber\Downloads\Projetos\example\src\main\java</sourceDirectory>
        <scriptSourceDirectory>C:\Users\Kleber\Downloads\Projetos\example\src\main\scripts</scriptSourceDirectory>
        <testSourceDirectory>C:\Users\Kleber\Downloads\Projetos\example\src\test\java</testSourceDirectory>
        <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\classes</outputDirectory>
        <testOutputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\test-classes</testOutputDirectory>
        <resources>
          <resource>
            <directory>C:\Users\Kleber\Downloads\Projetos\example\src\main\resources</directory>
          </resource>
        </resources>
        <testResources>
          <testResource>
            <directory>C:\Users\Kleber\Downloads\Projetos\example\src\test\resources</directory>
          </testResource>
        </testResources>
        <directory>C:\Users\Kleber\Downloads\Projetos\example\target</directory>
        <finalName>example-0.0.1-SNAPSHOT</finalName>
        <pluginManagement>
          <plugins>
            <plugin>
              <artifactId>maven-antrun-plugin</artifactId>
              <version>1.3</version>
            </plugin>
            <plugin>
              <artifactId>maven-assembly-plugin</artifactId>
              <version>2.2-beta-5</version>
            </plugin>
            <plugin>
              <artifactId>maven-dependency-plugin</artifactId>
              <version>2.1</version>
            </plugin>
            <plugin>
              <artifactId>maven-release-plugin</artifactId>
              <version>2.0</version>
            </plugin>
          </plugins>
        </pluginManagement>
        <plugins>
          <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
              <url>http://localhost:8080/manager/text</url>
              <server>TomcatServer</server>
              <path>/webappExample</path>
              <username>user001</username>
              <password>123</password>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.4.1</version>
            <executions>
              <execution>
                <id>default-clean</id>
                <phase>clean</phase>
                <goals>
                  <goal>clean</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.3.1</version>
            <executions>
              <execution>
                <id>default-install</id>
                <phase>install</phase>
                <goals>
                  <goal>install</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.5</version>
            <executions>
              <execution>
                <id>default-resources</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>resources</goal>
                </goals>
              </execution>
              <execution>
                <id>default-testResources</id>
                <phase>process-test-resources</phase>
                <goals>
                  <goal>testResources</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.10</version>
            <executions>
              <execution>
                <id>default-test</id>
                <phase>test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <executions>
              <execution>
                <id>default-testCompile</id>
                <phase>test-compile</phase>
                <goals>
                  <goal>testCompile</goal>
                </goals>
              </execution>
              <execution>
                <id>default-compile</id>
                <phase>compile</phase>
                <goals>
                  <goal>compile</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <executions>
              <execution>
                <id>default-war</id>
                <phase>package</phase>
                <goals>
                  <goal>war</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.7</version>
            <executions>
              <execution>
                <id>default-deploy</id>
                <phase>deploy</phase>
                <goals>
                  <goal>deploy</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.0</version>
            <executions>
              <execution>
                <id>default-site</id>
                <phase>site</phase>
                <goals>
                  <goal>site</goal>
                </goals>
                <configuration>
                  <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory>
                  <reportPlugins>
                    <reportPlugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-project-info-reports-plugin</artifactId>
                    </reportPlugin>
                  </reportPlugins>
                </configuration>
              </execution>
              <execution>
                <id>default-deploy</id>
                <phase>site-deploy</phase>
                <goals>
                  <goal>deploy</goal>
                </goals>
                <configuration>
                  <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory>
                  <reportPlugins>
                    <reportPlugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-project-info-reports-plugin</artifactId>
                    </reportPlugin>
                  </reportPlugins>
                </configuration>
              </execution>
            </executions>
            <configuration>
              <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <reporting>
        <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory>
      </reporting>
    </project>
    

    In this moment, in the Markers tab on my Eclipse IDE, this error is being presented:

    Description Resource    Path    Location    Type
    Dynamic Web Module 3.0 requires Java 1.6 or newer.  example     line 1  Maven Java EE Configuration Problem
    One or more constraints have not been satisfied.    example     line 1  Maven Java EE Configuration Problem
    

    I try fix this configuration in the Build path from my project (In Properties/Java Build Path), but when I run Maven > Update Project, the value for this option returned to the previous one.

    Where I should change this option to fix this error?

    解决方案

    1. Go to project Build Path and change the Java Library version to 1.7
    2. Go to Eclipse Preferences -> Java -> Compilre -> Change compliance level to 1.7

    3. Right click on project -> Properties -> Project Facets
    4. Uncheck Dynamic Web Module and click Apply (also uncheck JavaServer Faces if you had that)
    5. Change the Java facet version to 1.7 and click Apply
    6. Add the Dyanmic Web Module v3.0, apply.

    Eclipse's facets configuration is buggy. Make sure you keep hitting Apply between checking and unchecking of facets.

    Links:

  • Cannot change version of project facet Dynamic Web Module to 3.0?
  • Change version of project facet Dynamic Web Module to 2.5

    这篇关于Maven Java EE配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆