2011-08-24 38 views
1

我在阅读Spring in Action时遇到了这个错误:第3版:第1章我设法从网站工作。我的IDE是STS。由于Spring in Action:第3版:第1章... Maven和POM文件

[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Unnamed - Knights:Knights:jar:0.0.1-SNAPSHOT 
[INFO] task-segment: [install] 
[INFO] ------------------------------------------------------------------------ 
[INFO] [resources:resources {execution: default-resources}] 
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! 
[INFO] Copying 1 resource 
[INFO] [compiler:compile {execution: default-compile}] 
[INFO] Compiling 7 source files to E:\SpringInAction\Knights\target\classes 
[INFO] [resources:testResources {execution: default-testResources}] 
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! 
[INFO] skip non existing resourceDirectory E:\SpringInAction\Knights\src\test\resources 
[INFO] [compiler:testCompile {execution: default-testCompile}] 
[INFO] Compiling 1 source file to E:\SpringInAction\Knights\target\test-classes 
[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Compilation failure 

E:\SpringInAction\Knights\src\test\java\com\springinaction\knights\BraveKnightTest.java:[3,7] static import declarations are not supported in -source 1.3 
(use -source 5 or higher to enable static import declarations) 
import static org.mockito.Mockito.*; 

E:\SpringInAction\Knights\src\test\java\com\springinaction\knights\BraveKnightTest.java:[8,3] annotations are not supported in -source 1.3 
(use -source 5 or higher to enable annotations) 
    @Test 


[INFO] ------------------------------------------------------------------------ 
[INFO] For more information, run Maven with the -e switch 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1 second 
[INFO] Finished at: Wed Aug 24 00:12:45 CDT 2011 
[INFO] Final Memory: 12M/232M 
[INFO] ----------------------------------------------------------- 

回答

2

添加到您的POM为了告诉Maven来使用Java的版本5,默认情况下它使用1.3版(see documentation):

<build> 
    <pluginManagement> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <configuration> 
      <source>1.5</source> 
      <target>1.5</target> 
     </configuration> 
     </plugin> 
    </plugins> 
    </pluginManagement> 
</build> 
+0

是Maven的欲以1.3 ? 谢谢! –

+0

源属性实际上默认为1.3(请参阅http://maven.apache.org/maven-1.x/plugins/java/properties.html) –

相关问题