Maven 下载不正确的 Spring jar 版本
Maven downloading incorrect Spring jar versions
一段时间以来,我一直在努力寻找解决此问题的方法,但没有成功。我在我的 bean xml 中使用的命名空间如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jdbc
http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<beans profile="dev, local">
<bean id="emailVerificationMessageStore" class="org.springframework.integration.store.SimpleMessageStore"/>
</beans>
<beans profile="production, staging">
<int-jdbc:message-store id="emailVerificationMessageStore" data-source="dataSource" region="emailVerification"/>
</beans>
配置文件元素位于文件末尾,如上所示。
当我部署到我的 tomcat 服务器时,我看到以下错误:
Line 58 in XML document from URL [file:/var/lib/tomcat6/webapps/project/WEB-INF/classes/META-INF/spring/context.xml]
is invalid; nested exception is org.xml.sax.SAXParseException;
lineNumber: 58; columnNumber: 33;
cvc-complex-type.2.4.a: Invalid content was found starting with element 'beans'.
One of '{"http://www.springframework.org/schema/beans":import,
"http://www.springframework.org/schema/beans":alias,
"http://www.springframework.org/schema/beans":bean,
WC[##other:"http://www.springframework.org/schema/beans"]}' is expected.
我 运行 mvn dependency:tree 看到 maven 正在下载正确的 jar 版本,似乎即使我在 Pom.Xml 中指定了最新版本它正在下载 3.0。 0 个罐子:
--- maven-dependency-plugin:2.8:tree (default-cli) @ services ---
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-aop/3.0.0.RC3/spring-aop-3.0.0.RC3.jar
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-context/3.0.0.RC3/spring-context-3.0.0.RC3.jar
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-asm/3.0.0.RC3/spring-asm-3.0.0.RC3.jar
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-core/3.0.0.RC3/spring-core-3.0.0.RC3.jar
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-beans/3.0.0.RC3/spring-beans-3.0.0.RC3.ja
如何强制 maven 下载更高版本的 jar?
使用 eclipse 的依赖层次结构工具找到了这个问题的答案,似乎导入的 Jersey jar 包含 Spring 3.0.0,因此覆盖了我的其他 jar。
添加这个已经解决了问题:
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>1.8</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency>
一段时间以来,我一直在努力寻找解决此问题的方法,但没有成功。我在我的 bean xml 中使用的命名空间如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jdbc
http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<beans profile="dev, local">
<bean id="emailVerificationMessageStore" class="org.springframework.integration.store.SimpleMessageStore"/>
</beans>
<beans profile="production, staging">
<int-jdbc:message-store id="emailVerificationMessageStore" data-source="dataSource" region="emailVerification"/>
</beans>
配置文件元素位于文件末尾,如上所示。 当我部署到我的 tomcat 服务器时,我看到以下错误:
Line 58 in XML document from URL [file:/var/lib/tomcat6/webapps/project/WEB-INF/classes/META-INF/spring/context.xml]
is invalid; nested exception is org.xml.sax.SAXParseException;
lineNumber: 58; columnNumber: 33;
cvc-complex-type.2.4.a: Invalid content was found starting with element 'beans'.
One of '{"http://www.springframework.org/schema/beans":import,
"http://www.springframework.org/schema/beans":alias,
"http://www.springframework.org/schema/beans":bean,
WC[##other:"http://www.springframework.org/schema/beans"]}' is expected.
我 运行 mvn dependency:tree 看到 maven 正在下载正确的 jar 版本,似乎即使我在 Pom.Xml 中指定了最新版本它正在下载 3.0。 0 个罐子:
--- maven-dependency-plugin:2.8:tree (default-cli) @ services ---
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-aop/3.0.0.RC3/spring-aop-3.0.0.RC3.jar
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-context/3.0.0.RC3/spring-context-3.0.0.RC3.jar
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-asm/3.0.0.RC3/spring-asm-3.0.0.RC3.jar
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-core/3.0.0.RC3/spring-core-3.0.0.RC3.jar
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-beans/3.0.0.RC3/spring-beans-3.0.0.RC3.ja
如何强制 maven 下载更高版本的 jar?
使用 eclipse 的依赖层次结构工具找到了这个问题的答案,似乎导入的 Jersey jar 包含 Spring 3.0.0,因此覆盖了我的其他 jar。
添加这个已经解决了问题:
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>1.8</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency>