【问题标题】:Project has dependencies in maven that are not resolved locally (Spring-security dependencies)项目在 Maven 中具有未在本地解析的依赖项(Spring-security 依赖项)
【发布时间】:2016-12-25 08:54:10
【问题描述】:

我尝试使用 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

我该如何解决?

【问题讨论】:

  • 你在代理后面吗?
  • 能否提供来自 Maven 的完整错误消息?
  • @A_Di-Matteo 不,我不使用任何代理
  • @Daniel 我编辑我的问题。请参阅已编辑问题中的整个错误
  • 你有什么理由不从 maven Central 获取 Spring 框架吗?我从来没有用过http://maven.springframework.org/release...

标签: spring maven spring-security


【解决方案1】:

我可以毫无错误地构建项目。请查看日志作为证据:在我看来,您正在代理后面运行。如果是,则需要修复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] ------------------------------------------------------------------------

【讨论】:

  • 我正在使用 netbeans abs IDE 和默认设置:无代理。我测试了连接并且工作正常
【解决方案2】:

在独立的纯 Spring 项目中,始终尝试使用相同版本的框架模块以避免不兼容问题。否则,如果您不想自己管理依赖项,请使用 Spring Boot。但这应该可以正常工作。

【讨论】:

    猜你喜欢
    • 2018-02-27
    • 2017-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 1970-01-01
    • 1970-01-01
    • 2016-03-08
    相关资源
    最近更新 更多