STS Maven编译 无效的目标版本

从JDK1.7编译通过的Web项目移植到JDK1.6 Maven,出现错误:

javac: 无效的目标版本: 1.7

使用Maven插件,修改JDK编译版本:

方法一:修改maven全局jdk

    

    修改 安装目录\maven2\conf\settings.xml

 <profiles>   
       <profile>     
            <id>jdk-1.6</id>     
            <activation>     
                <activeByDefault>true</activeByDefault>     
                <jdk>1.6</jdk>     
            </activation>     
            <properties>     
                <maven.compiler.source>1.6</maven.compiler.source>     
                <maven.compiler.target>1.6</maven.compiler.target>     
                <maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>     
            </properties>     
    </profile>    
 </profiles>  

方式二、修改项目pom.xml

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

参考资料:

http://lyking2001.iteye.com/blog/837440

猜你喜欢

转载自paladin1988.iteye.com/blog/2080552
sts