java - 尝试使用 Maven 构建第一个 Spring 项目

标签 java spring maven

我正在尝试使用 maven 构建我的第一个 Spring 项目,它在使用 maven 之前可以正常工作,但现在我正在尝试使用 maven 进行构建,我得到以下输出。有人能告诉我发生了什么事吗

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building WebFlowTemplate Maven Webapp
[INFO]    task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 5 source files to /home/jsmith/Downloads/home/jsmith/Documents/workspace-sts-3.0.0/WebFlowTemplate/target/classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

/home/jsmith/Downloads/home/jsmith/Documents/workspace-sts-3.0.0/WebFlowTemplate/src/main/java/org/uftwf/webflowtemplate/service/TestServiceImpl.java:[9,1] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Service

/home/jsmith/Downloads/home/jsmith/Documents/workspace-sts-3.0.0/WebFlowTemplate/src/main/java/org/uftwf/webflowtemplate/controller/HelloWorldController.java:[8,1] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Controller

/home/jsmith/Downloads/home/jsmith/Documents/workspace-sts-3.0.0/WebFlowTemplate/src/main/java/org/uftwf/webflowtemplate/controller/swf/HellowWorldFlowActions.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.apache.log4j.Logger.getLogger;

/home/jsmith/Downloads/home/jsmith/Documents/workspace-sts-3.0.0/WebFlowTemplate/src/main/java/org/uftwf/webflowtemplate/controller/swf/HellowWorldFlowActions.java:[13,1] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Component

/home/jsmith/Downloads/home/jsmith/Documents/workspace-sts-3.0.0/WebFlowTemplate/src/main/java/org/uftwf/webflowtemplate/domain/Customer.java:[7,1] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@SuppressWarnings("serial")


[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Thu Sep 13 22:09:00 EDT 2012
[INFO] Final Memory: 19M/163M
[INFO] ------------------------------------------------------------------------

这是我的 pox.xml 文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springsource.greenbeans.maven</groupId>
    <artifactId>WebFlowTemplate</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>WebFlowTemplate Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
<!-- 
<dependency>
        <groupId>org.jasig.cas</groupId>
        <artifactId>cas-server-core</artifactId>
        <version>3.5.0</version>
        <exclusions>
            <exclusion>
                <artifactId>jcl-over-slf4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.6.6</version>
    </dependency>

-->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.3.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.3.0.Final</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjtools</artifactId>
            <version>1.6.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.webflow</groupId>
            <artifactId>spring-webflow</artifactId>
            <version>2.3.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-ldap</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-cas</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-cas-client</artifactId>
            <version>3.0.7.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>


        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.ldap</groupId>
            <artifactId>spring-ldap-core</artifactId>
            <version>1.3.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.ldap</groupId>
            <artifactId>spring-ldap-core-tiger</artifactId>
            <version>1.3.0.RELEASE</version>
        </dependency>

<!-- 
        <dependency>
            <groupId>org.jasig.cas</groupId>
            <artifactId>cas-server-core</artifactId>
            <version>3.5.0</version>
        </dependency>
 -->
        <dependency>
            <groupId>org.jasig.cas.client</groupId>
            <artifactId>cas-client-core</artifactId>
            <version>3.1.12</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.6</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-ext</artifactId>
            <version>1.6.6</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.6</version>
        </dependency>
<!-- 
        <dependency>
            <groupId>org.apache.directory.server</groupId>
            <artifactId>apacheds-core</artifactId>
            <version>1.5.5</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.directory.server</groupId>
            <artifactId>apacheds-server-jndi</artifactId>
            <version>1.5.5</version>
            <scope>runtime</scope>
        </dependency>
 -->
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-jsp</artifactId>
            <version>2.2.2</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-nop</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    </dependencies>
    <build>
        <finalName>WebFlowTemplate</finalName>

    </build>
</project>

最佳答案

看来您使用的是 1.5 之前的 JDK 版本。自 JDK 1.5 以来就引入了 java 中的注释支持,您应该将项目配置为使用 1.5 或更高版本运行,如下所示:

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

关于java - 尝试使用 Maven 构建第一个 Spring 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12417268/

相关文章:

java - 调试/查看 GWT 生成的 java 代码的源代码

java - 更改 ObjectMap 以存储在 json Libgdx 中

java - Java序列化如何保证枚举的一致性?

java - 属性<beans :property name ="maximumSessions" value ="1"/> doesn't work

maven - Maven 为 JDK9 做好准备了吗?

java - 从 Java 6 SE 迁移到 Java 6 EE

java - 在 Spring JPA 中的字段上使用 @Enumerated 和 @Formula 以及 Case

spring - 使用单个请求发送 JSON 和图像。 Angular + Spring 引导

java - 将 javassist 字节码操作与 maven 编译集成

java - NullPointerException : ProGuard, Spring 启动