Maven Java EE配置
在我的maven项目中,我有这个有效的POM:
4.0.0 spring example 0.0.1-SNAPSHOT war example http://maven.apache.org UTF-8 org.springframework spring-context 4.0.3.RELEASE compile org.springframework.ws spring-ws-core 2.1.4.RELEASE compile org.springframework.security spring-security-web 3.2.3.RELEASE compile org.springframework.security spring-security-config 3.2.3.RELEASE compile org.hibernate hibernate-core 4.3.5.Final compile org.hibernate hibernate-validator 5.1.0.Final compile org.springframework spring-orm 4.0.3.RELEASE compile org.springframework spring-tx 4.0.3.RELEASE compile false central Central Repository http://repo.maven.apache.org/maven2 never false central Central Repository http://repo.maven.apache.org/maven2 C:\Users\Kleber\Downloads\Projetos\example\src\main\java C:\Users\Kleber\Downloads\Projetos\example\src\main\scripts C:\Users\Kleber\Downloads\Projetos\example\src\test\java C:\Users\Kleber\Downloads\Projetos\example\target\classes C:\Users\Kleber\Downloads\Projetos\example\target\test-classes C:\Users\Kleber\Downloads\Projetos\example\src\main\resources C:\Users\Kleber\Downloads\Projetos\example\src\test\resources C:\Users\Kleber\Downloads\Projetos\example\target example-0.0.1-SNAPSHOT maven-antrun-plugin 1.3 maven-assembly-plugin 2.2-beta-5 maven-dependency-plugin 2.1 maven-release-plugin 2.0 org.apache.tomcat.maven tomcat7-maven-plugin 2.2 http://localhost:8080/manager/text TomcatServer /webappExample user001 123 maven-clean-plugin 2.4.1 default-clean clean clean maven-install-plugin 2.3.1 default-install install install maven-resources-plugin 2.5 default-resources process-resources resources default-testResources process-test-resources testResources maven-surefire-plugin 2.10 default-test test test maven-compiler-plugin 2.3.2 default-testCompile test-compile testCompile default-compile compile compile maven-war-plugin 2.1.1 default-war package war maven-deploy-plugin 2.7 default-deploy deploy deploy maven-site-plugin 3.0 default-site site site C:\Users\Kleber\Downloads\Projetos\example\target\site org.apache.maven.plugins maven-project-info-reports-plugin default-deploy site-deploy deploy C:\Users\Kleber\Downloads\Projetos\example\target\site org.apache.maven.plugins maven-project-info-reports-plugin C:\Users\Kleber\Downloads\Projetos\example\target\site org.apache.maven.plugins maven-project-info-reports-plugin C:\Users\Kleber\Downloads\Projetos\example\target\site
在这一刻,在Eclipse IDE的Markers选项卡中,出现了这个错误:
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
我尝试在我的项目的Build路径中修改此配置(在Properties / Java Build Path中),但是当我运行Maven> Update Project时,此选项的值返回到前一个。
我应该在哪里更改此选项以修复此错误?
- 转到项目
Build Path
并将Java库版本更改为1.7
- 转到Eclipse首选项 – > Java – >编译器 – >将合规性级别更改为
1.7
- 右键单击项目 – >属性 – >项目构面
- 取消选中
Dynamic Web Module
并单击Apply (如果有,也取消选中JavaServer Faces
) - 将
Java
构面版本更改为1.7
,然后单击“ 应用” - 添加
Dyanmic Web Module v3.0
,申请。
Eclipse的facet配置有缺陷。 确保在检查和取消检查方面之间继续点击“ Apply
。
链接:
GGrec的解决方案对我不起作用。 我设法通过添加到pom.xml来修复此问题:
finalName maven-compiler-plugin 3.1 1.8 1.8
更新:此外我发现每次在这个pom.xml上运行mvn install命令时它都会覆盖以前的配置。 正确的解决方案是从pom.xml中删除此版本并在eclipse选项中进行设置,或者只使用pom.xml中的配置。
完成上述故障排除步骤后。 更新您的maven项目。
右键单击您的项目 – > Maven – > Update Project
或者只是Alt + f5。
希望这可以帮助某人。
另外作为Kefas我指定java版本为1.7,它的工作原理!
maven-compiler-plugin 3.1 1.7 1.7
以上建议对我有帮助! 右键单击项目 – >属性 – >项目构面,然后将Java构面版本更改为1.7。
如果它不起作用,请将以下代码添加到pom.xml:
finalName org.apache.maven.plugins maven-compiler-plugin 3.1 1.7 1.7
保存pom.xml。
然后,右键单击项目 – > Maven – >更新项目。
这可能听起来很傻,但我只做了Project-> Clean,然后是Maven-> Update。
解决了这个问题。
我使用的是java 1.8。 修复了以下操作。
从pom中删除:
maven-compiler-plugin 3.5.1 1.8 1.8
它会抱怨pom不是最新的。 使用快速修复更新,然后你得到一大堆错误。
重新添加到pom:
maven-compiler-plugin 3.5.1 1.8 1.8
更新了maven并清除了所有错误。
这对我有用:
org.apache.maven.plugins maven-compiler-plugin 3.3 1.8 1.8 org.apache.maven.plugins maven-war-plugin 2.6 src/main/webapp mfp false myprojectname
将版本更改为3.1,将标记更改为1.7
maven-compiler-plugin 3.1 1.7 1.7
我不得不将Window-> Preferences-> Maven-> User Settings中的maven设置重置为“C:\ Development \ apache-maven-3.5.3 \ conf \ settings.xml”。