- 选择创建new project
- 勾选跳过创建类型选择(让eclipse创建标准maven项目)
- 填写组织ID,唯一ID,注意:如果选择打包类型为war包时,会生成web类型的maven工程
- 修改JRE编译环境为1.7
- 修改Dynamic Web Module和Jave 版本为1.7
- 增加仓库位置,增加插件build指定编译环境为1.7
<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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>spring-security-test</groupId> <artifactId>spring-security-test</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <!-- 仓库定义 --> <repositories> <!-- oschina的仓库 --> <repository> <id>oschina</id> <url>http://maven.oschina.net/content/groups/public</url> </repository> <!-- Activiti的仓库 --> <repository> <id>Activiti</id> <url>https://maven.alfresco.com/nexus/content/repositories/activiti</url> </repository> <!-- Codehaus的仓库 --> <repository> <id>Codehaus</id> <url>http://repository.codehaus.org</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>3.1.0.RELEASE</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> </project>
- 最后Maven Update Project
注意:
- 一定保持编译环境的一致性;
- 如果遇到Java Build Path - project cannot be read or is not a valid ZIP file,可以考虑找到maven仓库里找到读取不到的文件,删除,然后再重新update。
参考资料:http://crunchify.com/how-to-solve-dynamic-web-module-3-1-requires-java-1-7-or-newer-in-eclipse/
时间: 2024-11-06 19:33:30