Java 缺少工件 org.springframework:spring-context:jar:${org.springframework-version}
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36729549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Missing artifact org.springframework:spring-context:jar:${org.springframework-version}
提问by Blaze
Please why am I getting this error in my pom.xml file
请问为什么我的 pom.xml 文件中出现此错误
Missing artifact org.springframework:spring-context:jar:${org.springframework-version}
xml file
xml文件
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework-version}</version>
</dependency>
采纳答案by Tunaki
What you are seeing as ${...}
is called a Maven property:
您所看到${...}
的称为Maven 属性:
Maven properties are value placeholder, like properties in Ant. Their values are accessible anywhere within a POM by using the notation
${X}
, whereX
is the property.
Maven 属性是值占位符,就像 Ant 中的属性一样。它们的值可以通过使用表示法在 POM 中的任何位置访问
${X}
,其中X
是属性。
In this case, Maven is trying to access the property org.springframework-version
but it isn't defined, so nothing gets replaced.
在这种情况下,Maven 正在尝试访问该属性org.springframework-version
但它没有被定义,所以没有任何东西被替换。
You define your own Maven propertieswith the help of the <properties>
section in the POM:
您可以在 POM中的部分的帮助下定义自己的 Maven 属性<properties>
:
<properties>
<org.springframework-version>4.2.5.RELEASE</org.springframework-version> <!-- wanted Spring version -->
<hibernate.version>5.1.0.Final</hibernate.version> <!-- wanted Hibernate version -->
</properties>
回答by JonathanAmos
It is very likely you have not added the spring version number to your pom properties. Add this to your pom.
您很可能没有将 spring 版本号添加到您的 pom 属性中。将此添加到您的 pom.xml 文件中。
<properties>
<org.springframework-version>4.2.5.RELEASE</org.springframework-version>
</properties>
Change the version to any version of your choice for your project.
将版本更改为您为项目选择的任何版本。