使用JRE 1.5,仍然maven说-source 1.3中不支持注释

Abh*_*eet 4 java maven

我正在使用JRE 1.5.仍然当我尝试编译我的代码时,它失败了说使用JRE 1.5而不是1.3

C:\ temp\SpringExample> mvn -e clean install +错误堆栈跟踪已打开.[INFO]扫描项目... [INFO] -------------------------------------- ---------------------------------- [INFO]构建SpringExample [INFO]任务段:[清理,安装] [INFO] ---------------------------------------------- -------------------------- [INFO] [clean:clean {execution:default-clean}] [INFO]删除目录C:\ temp\SpringExample\target [INFO] [resources:resources {execution:default-resources}] [警告]使用平台编码(实际上是Cp1252)来复制过滤后的资源,即构建依赖于平台![INFO]复制6个资源[INFO] [编译器:compile {execution:default-compile}] [INFO]将6个源文件编译为C:\ temp\SpringExample\target\classes [INFO] -------- -------------------------------------------------- -------------- [ERROR] BUILD FAILURE [INFO] ---------------------------- -------------------------------------------- [INFO]编译失败C. :\ temp\Spring\sample\src\main\java\com\mkyong\stock\model\Stock.java:-source 1.3不支持[45,9]注释(尝试-source 1.5启用注释)@Override

[INFO] ----------------------------------------------- ------------------------- [INFO]跟踪org.apache.maven.BuildFailureException:编译失败C:\ temp\SpringExample\src\main\java\com\mkyong\stock\model\Stock.java:-source 1.3不支持[45,9]注释(试试-source 1.5启用注释)@Override

    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Run Code Online (Sandbox Code Playgroud)

引起:org.apache.maven.plugin.CompilationFailureException:编译失败C:\ temp\SpringExample\src\main\java\com\mkyong\stock\model\Stock.java:[45,9]注释不受支持-source 1.3(try -source 1.5启用注释)@Override

    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
Run Code Online (Sandbox Code Playgroud)

[INFO] ----------------------------------------------- ------------------------- [INFO]总时间:2秒[INFO]完成时间:12月22日星期三10:04:53 IST 2010 [ INFO]最终记忆:9M/16M [INFO] --------------------------------------- --------------------------------- C:\ temp\SpringExample> javac -version javac 1.5.0_08 javac:no源文件

Rag*_*ram 7

你有类似下面的东西来指定maven编译器插件使用的java版本吗?

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)


rzy*_*mek 5

更短的版本

<project>
    <properties>
        <maven.compiler.source>1.5</maven.compiler.source>
        <maven.compiler.target>1.5</maven.compiler.target>
    </properties>
....
Run Code Online (Sandbox Code Playgroud)