java - Spring 实践 : 3rd edition: Chapter 1. ..Maven 和 POM 文件

标签 java spring

我在阅读《Spring in Action:第三版:第 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] -----------------------------------------------------------
<小时/>

最佳答案

将其添加到您的 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>

关于java - Spring 实践 : 3rd edition: Chapter 1. ..Maven 和 POM 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7170744/

相关文章:

java - 使用正则表达式分割不同长度的字符串

java - 如何让聊天程序服务器向所有连接的java客户端发送消息

java - Spring返回自定义消息未按预期返回

java - 初始化打包在 jar 文件中的 Spring bean

Spring应用程序上下文外部属性?

java - 将用户名传递给 Spring Security

java - 在 Spring 中克隆现有的 ApplicationContext

bug-tracking - 我可以在哪里提交有关 FOSS Java Sound 实现 org.classpath.icedtea.pulseaudio.PulseAudioSourceDataLine 的错误报告?

java - 选择具有 between where 限定符的命名参数查询

java - JSF 状态最初保存到服务器和 session 超时传输到客户端?