spring-webmvc 4.2.3和4.2.2不兼容?

时间:2015-12-07 16:11:30

标签: spring spring-mvc spring-security

我正在试验Spring Security。内置登录页面可以显示:

  • 弹簧webmvc-4.2。的 2 .RELEASE
  • 弹簧安全核心4.0.3.RELEASE

这是jars的good组合:

This is the good combination of jars

但是当我改为:

  • 弹簧webmvc-4.2。的 3 .RELEASE
  • 弹簧安全核心4.0.3.RELEASE

这是jars的failed组合:

This is the failed combination of jars

启动tomcat时遇到以下错误。这种微小变化怎么可能兼容

我的pom.xml非常简单,我only指定org.springframework.versionorg.springframework.security.version,这两者都是最新的。所有其他人都是transitive dependencies我完全leave to Maven

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>mygroup</groupId>
  <artifactId>mycloud-server</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <properties>
    <org.springframework.version>4.2.3.RELEASE</org.springframework.version>
    <org.springframework.security.version>4.0.3.RELEASE</org.springframework.security.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>



  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${org.springframework.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${org.springframework.security.version}</version>
    </dependency>

  </dependencies>

  <build>
     <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
            <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
         </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.1</version>
          <configuration>
            <source>1.7</source>
            <target>1.7</target>
          </configuration>
        </plugin>

     </plugins>
  </build>
</project>
  

2015年12月8日12:04:26 org.springframework.web.context.ContextLoader initWebApplicationContext   严重:上下文初始化失败   java.lang.NoSuchMethodError:   org.springframework.aop.framework.autoproxy.AutoProxyUtils.determineTargetClass(Lorg / springframework的/豆类/厂/配置/ ConfigurableListableBeanFactory; Ljava /郎/字符串;)Ljava /郎/类;     在   org.springframework.context.event.EventListenerMethodProcessor.afterSingletonsInstantiated(EventListenerMethodProcessor.java:78)     在   org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792)     在   org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)     在   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)     在   org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)     在   org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)     在   org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)     在   org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4770)     在   org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)     在   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)     在   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1409)     在   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1399)     在java.util.concurrent.FutureTask.run(FutureTask.java:262)at   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615)     在java.lang.Thread.run(Thread.java:745)

     

2015年12月8日上午12:04:26 org.apache.catalina.core.StandardContext   listenerStart SEVERE:将上下文初始化事件发送到的异常   类的监听器实例   org.springframework.web.context.ContextLoaderListener   java.lang.NoSuchMethodError:   org.springframework.aop.framework.autoproxy.AutoProxyUtils.determineTargetClass(Lorg / springframework的/豆类/厂/配置/ ConfigurableListableBeanFactory; Ljava /郎/字符串;)Ljava /郎/类;     在   org.springframework.context.event.EventListenerMethodProcessor.afterSingletonsInstantiated(EventListenerMethodProcessor.java:78)     在   org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792)     在   org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)     在   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)     在   org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)     在   org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)     在   org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)     在   org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4770)     在   org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)     在   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)     在   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1409)     在   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1399)     在java.util.concurrent.FutureTask.run(FutureTask.java:262)at   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615)     在java.lang.Thread.run(Thread.java:745)

     

2015年12月8日上午12:04:26 org.apache.catalina.core.StandardContext   startInternal 严重:错误listenerStart 2015年12月8日12:04:26 AM   org.apache.catalina.core.StandardContext startInternal SEVERE:Context   [/ mycloud-server]启动因以前的错误而失败 2015年12月8日   上午12:04:26 org.apache.catalina.core.ApplicationContext log INFO:   关闭Spring root WebApplicationContext 2015年12月8日上午12:04:26   org.springframework.web.context.support.AnnotationConfigWebApplicationContext   doClose INFO:关闭根WebApplicationContext:启动日期[星期二   12月08日00:04:25 CST 2015];上下文层次结构2015年12月8日   上午12:04:26   org.springframework.web.context.support.AnnotationConfigWebApplicationContext   doClose警告:在上下文中从LifecycleProcessor抛出异常   close java.lang.IllegalStateException:没有LifecycleProcessor   初始化 - 调用&#39;刷新&#39;在通过之前调用生命周期方法之前   context:Root WebApplicationContext:启动日期[Tue Dec 08 00:04:25   CST 2015];上下文层次结构的根   org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:414)     在   org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:972)     在   org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:931)     在   org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:583)     在   org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116)     在   org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4813)     在   org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5413)     在   org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)     在   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)     在   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1409)     在   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1399)     在java.util.concurrent.FutureTask.run(FutureTask.java:262)at   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615)     在java.lang.Thread.run(Thread.java:745)

1 个答案:

答案 0 :(得分:0)

感谢@ M.Deinum的建议。我遵循这个link来使用Spring IO平台。

我在使用10G旧本地存储库的Maven更新期间遇到了一些奇怪的问题。 I solved it by using a new empty local repository.

它有效。使用maven dependency management非常简洁。

我的pom.xml现在看起来像这样:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>xxx</groupId>
    <artifactId>mycloud-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.spring.platform</groupId>
                <artifactId>platform-bom</artifactId>
                <version>2.0.0.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

所谓的managed dependency显示如下:

enter image description here

还有一些提示:

根据我的经验,许多Maven错误是由依赖项或插件的下载失败引起的。对于每次失败的下载,都将创建一个*.lastUpdated文件。有时此文件将阻止第二次下载尝试。您可以使用以下命令将其删除。

  1. cd到本地存储库。
  2. 运行:dir *.lastUpdated /s以识别所有这些内容。
  3. 运行:del *.lastUpdated /s删除所有这些内容。
  4. 再次在eclipse中运行Maven -> Update