我尝试使用Spring,但是在我的pom.xml中似乎存在一些问题,它无法解决Spring依赖关系。
在pom.xml中,我有以下存储库:
<repositories>
<repository>
<id>repository.springframework.maven.release</id>
<name>Spring Framework Maven Release Repository</name>
<url>http://maven.springframework.org/release</url>
</repository>
</repositories>
<!-- Spring Core framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<!-- Spring security framework -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.1.2.RELEASE</version>
</dependency>
我总是:无法解决项目的依赖关系,无法解析以下工件:
org.springframework.security:spring-security-web:jar:4.1.2.RELEASE
aopalliance:aopalliance:jar:1.0
org.springframework.security:spring-security-core:jar:4.1.2.RELEASE
org.springframework:spring-expression:jar:4.3.1.RELEASE
org.springframework.security:spring-security-config:jar:4.1.2.RELEASE
即使我在pom.xml中使用另一个存储库,甚至删除存储库以使用maven中的默认存储库,它也一样,没有任何改变。
Maven的完整错误消息:
Failed to execute goal on project Aegyptologie: Could not resolve dependencies for project de.unileipzig.wirote:Aegyptologie:war:0.1-SNAPSHOT: The following artifacts could not be resolved: org.springframework:spring-core:jar:4.3.2.RELEASE, org.springframework:spring-web:jar:4.3.2.RELEASE, org.springframework:spring-aop:jar:4.3.2.RELEASE, org.springframework:spring-beans:jar:4.3.2.RELEASE, org.springframework:spring-context:jar:4.3.2.RELEASE, org.springframework.security:spring-security-web:jar:4.1.2.RELEASE, aopalliance:aopalliance:jar:1.0, org.springframework.security:spring-security-core:jar:4.1.2.RELEASE, org.springframework:spring-expression:jar:4.3.1.RELEASE, org.springframework.security:spring-security-config:jar:4.1.2.RELEASE: Could not transfer artifact org.springframework:spring-core:jar:4.3.2.RELEASE from/to repository.springframework.maven.release (http://maven.springframework.org/release): Connection reset -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
我该如何解决?
答案 0 :(得分:0)
我可以毫无错误地构建项目。请将日志视为证据:我认为您在代理服务器后面运行。如果是,则需要修复apache-maven-3.x.x的conf / settings.xml文件
$ mvn clean install -DskipTests
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Aegyptologie 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://mvnrepository.com/artifact/org.springframework/org/springframework/security/spring-security-web/4.1.2.RELEASE/spring-security-web-4.1.2.RELEASE.pom
Downloading: https://repo.maven.apache.org/maven2/org/springframework/security/spring-security-web/4.1.2.RELEASE/spring-security-web-4.1.2.RELEASE.pom
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/security/spring-security-web/4.1.2.RELEASE/spring-security-web-4.1.2.RELEASE.pom (0 B at 0.0 KB/sec)
Downloading: https://mvnrepository.com/artifact/org.springframework/org/springframework/security/spring-security-core/4.1.2.RELEASE/spring-security-core-4.1.2.RELEASE.pom
Downloading: https://repo.maven.apache.org/maven2/org/springframework/security/spring-security-core/4.1.2.RELEASE/spring-security-core-4.1.2.RELEASE.pom
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/security/spring-security-core/4.1.2.RELEASE/spring-security-core-4.1.2.RELEASE.pom (0 B at 0.0 KB/sec)
Downloading: https://mvnrepository.com/artifact/org.springframework/org/springframework/security/spring-security-web/4.1.2.RELEASE/spring-security-web-4.1.2.RELEASE.jar
Downloading: https://mvnrepository.com/artifact/org.springframework/org/springframework/security/spring-security-core/4.1.2.RELEASE/spring-security-core-4.1.2.RELEASE.jar
Downloading: https://repo.maven.apache.org/maven2/org/springframework/security/spring-security-web/4.1.2.RELEASE/spring-security-web-4.1.2.RELEASE.jar
Downloading: https://repo.maven.apache.org/maven2/org/springframework/security/spring-security-core/4.1.2.RELEASE/spring-security-core-4.1.2.RELEASE.jar
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/security/spring-security-web/4.1.2.RELEASE/spring-security-web-4.1.2.RELEASE.jar (0 B at 0.0 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/security/spring-security-core/4.1.2.RELEASE/spring-security-core-4.1.2.RELEASE.jar (0 B at 0.0 KB/sec)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Aegyptologie ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Aegyptologie ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 29 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Aegyptologie ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 42 source files to e:\Advance Java\POI\Aegyptologie\target\classes
[WARNING] /e:/Advance Java/POI/Aegyptologie/src/main/java/de/unileipzig/wirote/control/Encoding.java: e:\Advance Java\POI\Aegyptologie\src\main\java\de\unileipzig\wirote\control\Encoding.java uses unchecked or uns
[WARNING] /e:/Advance Java/POI/Aegyptologie/src/main/java/de/unileipzig/wirote/control/Encoding.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Aegyptologie ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory e:\Advance Java\POI\Aegyptologie\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Aegyptologie ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ Aegyptologie ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ Aegyptologie ---
[INFO] Packaging webapp
[INFO] Assembling webapp [Aegyptologie] in [e:\Advance Java\POI\Aegyptologie\target\awv-seite]
[INFO] Processing war project
[INFO] Copying webapp resources [e:\Advance Java\POI\Aegyptologie\src\main\webapp]
[INFO] Webapp assembled in [6184 msecs]
[INFO] Building war: e:\Advance Java\POI\Aegyptologie\target\awv-seite.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ Aegyptologie ---
[INFO] Installing e:\Advance Java\POI\Aegyptologie\target\awv-seite.war to C:\Users\prateek\.m2\repository\de\unileipzig\wirote\Aegyptologie\0.1-SNAPSHOT\Aegyptologie-0.1-SNAPSHOT.war
[INFO] Installing e:\Advance Java\POI\Aegyptologie\pom.xml to C:\Users\prateek\.m2\repository\de\unileipzig\wirote\Aegyptologie\0.1-SNAPSHOT\Aegyptologie-0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 42.299 s
[INFO] Finished at: 2016-08-19T01:49:13+05:30
[INFO] Final Memory: 29M/320M
[INFO] ------------------------------------------------------------------------
答案 1 :(得分:0)
在独立的纯Spring项目中,请始终尝试使用相同版本的框架模块,以避免不兼容的问题。否则,如果您不想自己管理依赖项,请使用Spring Boot。但这应该可以正常工作。