Spring in Action:第3版:第1章...... Maven和POM文件

时间:2011-08-24 05:16:31

标签: java spring

我在执行Spring in Action时遇到了这个错误:第3版:第1章。我设法从网站上获取源代码。我的IDE是STS。感谢

[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] -----------------------------------------------------------

1 个答案:

答案 0 :(得分: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>