无法使用Maven解决依赖关系。

huangapple go评论72阅读模式
英文:

unabel to resolve dependencies using maven

问题

我正在运行Maven 3.8.9,并且在pom.xml文件中有以下配置:

<repositories>
    <repository>
        <id>central</id>
        <name>Maven Repository Switchboard</name>
        <url>https://repo.maven.apache.org/maven2</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
    </pluginRepository>
</pluginRepositories>

而在settings.xml文件中有以下配置:

<mirror>
    <id>maven-default-http-blocker</id>
    <mirrorOf>external:http:*</mirrorOf>
    <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
    <url>http://0.0.0.0/</url>
    <blocked>true</blocked>
</mirror>

我收到以下错误,不确定我漏掉了什么:

Failed to collect dependencies at org.springframework.boot:spring-boot-starter-oauth2-client:jar:2.3.0.RC1
-> org.springframework.security:spring-security-oauth2-client:jar:5.3.1.RELEASE 
-> com.nimbusds:oauth2-oidc-sdk:jar:7.1.1 -> com.nimbusds:nimbus-jose-jwt:jar:8.8
-> net.minidev:json-smart:jar:[1.3.1,2.3]: No versions available for net.minidev:json-smart:jar:[1.3.1,2.3] within specified range -> [Help 1]
英文:

I am running maven 3.8.9 and this is what i have in pom.xml

 &lt;repositories&gt;
        &lt;repository&gt;
            &lt;id&gt;central&lt;/id&gt;
            &lt;name&gt;Maven Repository Switchboard&lt;/name&gt;
            &lt;url&gt;https://repo.maven.apache.org/maven2&lt;/url&gt;
        &lt;/repository&gt;
    &lt;/repositories&gt;
    &lt;pluginRepositories&gt;
        &lt;pluginRepository&gt;
            &lt;id&gt;spring-milestones&lt;/id&gt;
            &lt;name&gt;Spring Milestones&lt;/name&gt;
            &lt;url&gt;https://repo.spring.io/milestone&lt;/url&gt;
        &lt;/pluginRepository&gt;
    &lt;/pluginRepositories&gt;

This is what i have in settings.xml

   &lt;mirror&gt;
      &lt;id&gt;maven-default-http-blocker&lt;/id&gt;
      &lt;mirrorOf&gt;external:http:*&lt;/mirrorOf&gt;
      &lt;name&gt;Pseudo repository to mirror external repositories initially using HTTP.&lt;/name&gt;
      &lt;url&gt;http://0.0.0.0/&lt;/url&gt;
      &lt;blocked&gt;true&lt;/blocked&gt;
    &lt;/mirror&gt;

I get Below error not sure what i am missing

        Failed to collect dependencies at org.springframework.boot:spring-boot-starter-oauth2-client:jar:2.3.0.RC1
     -&gt; org.springframework.security:spring-security-oauth2-client:jar:5.3.1.RELEASE 
-&gt; com.nimbusds:oauth2-oidc-sdk:jar:7.1.1 -&gt; com.nimbusds:nimbus-jose-jwt:jar:8.8
 -&gt; net.minidev:json-smart:jar:[1.3.1,2.3]: No versions available for net.minidev:json-smart:jar:[1.3.1,2.3] within specified range -&gt; [Help 1]

答案1

得分: 1

如果您试图获取一个依赖项(而不是插件),请在repositories(而不是pluginRepositories)中定义一个条目。非常简单。

	<repositories>
		<repository>
			<id>spring-snapshots</id>
			<name>Spring Snapshots</name>
			<url>https://repo.spring.io/snapshot</url>
			<snapshots>
				<enabled>true</enabled>
				<updatePolicy>always</updatePolicy>
			</snapshots>
			<releases>
				<enabled>true</enabled>
				<updatePolicy>never</updatePolicy>
			</releases>
		</repository>
		<repository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/milestone</url>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
			<releases>
				<enabled>true</enabled>
			</releases>
		</repository>
		<repository>
			<id>repository.spring.release</id>
			<name>Spring GA Repository</name>
			<url>http://repo.spring.io/release</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
			<releases>
				<enabled>true</enabled>
				<updatePolicy>never</updatePolicy>
			</releases>
		</repository>
	</repositories>
	<pluginRepositories>
		<pluginRepository>
			<id>spring-snapshots</id>
			<name>Spring Snapshots</name>
			<url>https://repo.spring.io/plugins-snapshot</url>
			<snapshots>
				<enabled>true</enabled>
				<updatePolicy>always</updatePolicy>
			</snapshots>
			<releases>
				<enabled>true</enabled>
				<updatePolicy>never</updatePolicy>
			</releases>
		</pluginRepository>
		<pluginRepository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/plugins-milestone</url>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
			<releases>
				<enabled>true</enabled>
			</releases>
		</pluginRepository>
		<pluginRepository>
			<id>repository.spring.release</id>
			<name>Spring GA Repository</name>
			<url>http://repo.spring.io/plugins-release</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
			<releases>
				<enabled>true</enabled>
				<updatePolicy>never</updatePolicy>
			</releases>
		</pluginRepository>
	</pluginRepositories>
英文:

If you are trying to pull a dependency (not a plugin), define an entry in repositories (not pluginRepositories). That easy.

	&lt;repositories&gt;
		&lt;repository&gt;
			&lt;id&gt;spring-snapshots&lt;/id&gt;
			&lt;name&gt;Spring Snapshots&lt;/name&gt;
			&lt;url&gt;https://repo.spring.io/snapshot&lt;/url&gt;
			&lt;snapshots&gt;
				&lt;enabled&gt;true&lt;/enabled&gt;
				&lt;updatePolicy&gt;always&lt;/updatePolicy&gt;
			&lt;/snapshots&gt;
			&lt;releases&gt;
				&lt;enabled&gt;true&lt;/enabled&gt;
				&lt;updatePolicy&gt;never&lt;/updatePolicy&gt;
			&lt;/releases&gt;
		&lt;/repository&gt;
		&lt;repository&gt;
			&lt;id&gt;spring-milestones&lt;/id&gt;
			&lt;name&gt;Spring Milestones&lt;/name&gt;
			&lt;url&gt;https://repo.spring.io/milestone&lt;/url&gt;
			&lt;snapshots&gt;
				&lt;enabled&gt;true&lt;/enabled&gt;
			&lt;/snapshots&gt;
			&lt;releases&gt;
				&lt;enabled&gt;true&lt;/enabled&gt;
			&lt;/releases&gt;
		&lt;/repository&gt;
		&lt;repository&gt;
			&lt;id&gt;repository.spring.release&lt;/id&gt;
			&lt;name&gt;Spring GA Repository&lt;/name&gt;
			&lt;url&gt;http://repo.spring.io/release&lt;/url&gt;
			&lt;snapshots&gt;
				&lt;enabled&gt;false&lt;/enabled&gt;
			&lt;/snapshots&gt;
			&lt;releases&gt;
				&lt;enabled&gt;true&lt;/enabled&gt;
				&lt;updatePolicy&gt;never&lt;/updatePolicy&gt;
			&lt;/releases&gt;
		&lt;/repository&gt;
	&lt;/repositories&gt;
	&lt;pluginRepositories&gt;
		&lt;pluginRepository&gt;
			&lt;id&gt;spring-snapshots&lt;/id&gt;
			&lt;name&gt;Spring Snapshots&lt;/name&gt;
			&lt;url&gt;https://repo.spring.io/plugins-snapshot&lt;/url&gt;
			&lt;snapshots&gt;
				&lt;enabled&gt;true&lt;/enabled&gt;
				&lt;updatePolicy&gt;always&lt;/updatePolicy&gt;
			&lt;/snapshots&gt;
			&lt;releases&gt;
				&lt;enabled&gt;true&lt;/enabled&gt;
				&lt;updatePolicy&gt;never&lt;/updatePolicy&gt;
			&lt;/releases&gt;
		&lt;/pluginRepository&gt;
		&lt;pluginRepository&gt;
			&lt;id&gt;spring-milestones&lt;/id&gt;
			&lt;name&gt;Spring Milestones&lt;/name&gt;
			&lt;url&gt;https://repo.spring.io/plugins-milestone&lt;/url&gt;
			&lt;snapshots&gt;
				&lt;enabled&gt;true&lt;/enabled&gt;
			&lt;/snapshots&gt;
			&lt;releases&gt;
				&lt;enabled&gt;true&lt;/enabled&gt;
			&lt;/releases&gt;
		&lt;/pluginRepository&gt;
		&lt;pluginRepository&gt;
			&lt;id&gt;repository.spring.release&lt;/id&gt;
			&lt;name&gt;Spring GA Repository&lt;/name&gt;
			&lt;url&gt;http://repo.spring.io/plugins-release&lt;/url&gt;
			&lt;snapshots&gt;
				&lt;enabled&gt;false&lt;/enabled&gt;
			&lt;/snapshots&gt;
			&lt;releases&gt;
				&lt;enabled&gt;true&lt;/enabled&gt;
				&lt;updatePolicy&gt;never&lt;/updatePolicy&gt;
			&lt;/releases&gt;
		&lt;/pluginRepository&gt;
	&lt;/pluginRepositories&gt;

huangapple
  • 本文由 发表于 2023年2月18日 11:53:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75491065.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定