1. 程式人生 > >Maven專案Java Resoures資原始檔夾出現小紅叉解決方案

Maven專案Java Resoures資原始檔夾出現小紅叉解決方案

錯誤說明:eclipse+maven下Java Resoures資原始檔夾出現小紅叉。

錯誤提示內容:One or more constraints have not been satisfied.

錯誤原因: Deployment Assembly跟Java版本不匹配,即maven預設編譯版本與使用的jdk不匹配。

解決方案:在pom.xml中新增如下配置

<!-- 指定maven編譯方式為jdk1.7版本 -->  
<profiles>  
    <profile>  
        <id>jdk-1.7</id>
<activation> <activeByDefault>true</activeByDefault> <jdk>1.7</jdk> </activation> <properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target
>
1.7</maven.compiler.target> <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion> </properties> </profile> </profiles>