2015-11-23 109 views
1

我的項目使用Spring 4.2.2.RELEASE和Spring Security 4.0.3.RELEASE運行良好。我想升級到最新的Spring版本4.2.3.RELEASE以利用發行版中包含的錯誤修正。我使用Maven依賴管理,所以我調整我的POM看起來像這樣:當升級到4.2.3版時,Spring上下文初始化失敗

父項目POM:

<modules> 
    <module>api</module> 
    <module>model</module> 
</modules> 

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

    <spring.version>4.2.3.RELEASE</spring.version> 
    <spring-security.version>4.0.3.RELEASE</spring-security.version> 

    <!-- ... --> 
</properties> 

API POM:

<dependencies> 
    <!-- ... --> 

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

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

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

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

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

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

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

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

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

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

    <!-- ... --> 
</dependencies> 

當我嘗試使用maven運行我的項目,在運行時出現以下異常:

java.lang.IllegalArgumentException: interface org.springframework.core.annotation.SynthesizedAnnotation is not visible from class loader 
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:581) 
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557) 
at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230) 
at java.lang.reflect.WeakCache.get(WeakCache.java:127) 
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419) 
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719) 
at org.springframework.core.annotation.AnnotationUtils.synthesizeAnnotation(AnnotationUtils.java:1404) 
at org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation(AnnotatedElementUtils.java:405) 
at org.springframework.web.method.HandlerMethod.getMethodAnnotation(HandlerMethod.java:234) 
at com.mangofactory.swagger.readers.operation.OperationDeprecatedReader.execute(OperationDeprecatedReader.java:8) 
at com.mangofactory.swagger.readers.operation.OperationDeprecatedReader.execute(OperationDeprecatedReader.java:5) 
at com.mangofactory.swagger.core.CommandExecutor.execute(CommandExecutor.java:13) 
at com.mangofactory.swagger.readers.ApiOperationReader.execute(ApiOperationReader.java:112) 
at com.mangofactory.swagger.readers.ApiDescriptionReader.execute(ApiDescriptionReader.java:48) 
at com.mangofactory.swagger.readers.ApiDescriptionReader.execute(ApiDescriptionReader.java:19) 
at com.mangofactory.swagger.core.CommandExecutor.execute(CommandExecutor.java:13) 
at com.mangofactory.swagger.scanners.ApiListingScanner.scan(ApiListingScanner.java:100) 
at com.mangofactory.swagger.core.SwaggerApiResourceListing.initialize(SwaggerApiResourceListing.java:72) 
at com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin.initialize(SwaggerSpringMvcPlugin.java:427) 
at com.mangofactory.swagger.plugin.SwaggerPluginAdapter.onApplicationEvent(SwaggerPluginAdapter.java:51) 
at com.mangofactory.swagger.plugin.SwaggerPluginAdapter.onApplicationEvent(SwaggerPluginAdapter.java:21) 
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163) 
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136) 
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:380) 
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334) 
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:851) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540) 
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667) 
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:539) 
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493) 
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 
at javax.servlet.GenericServlet.init(GenericServlet.java:244) 
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:612) 
at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:395) 
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:871) 
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298) 
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1345) 
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp(JettyWebAppContext.java:296) 
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1338) 
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741) 
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:501) 
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:365) 
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) 
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) 
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) 
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) 
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:163) 
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) 
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) 
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) 
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) 
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) 
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) 
at org.eclipse.jetty.server.Server.start(Server.java:387) 
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) 
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) 
at org.eclipse.jetty.server.Server.doStart(Server.java:354) 
at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:73) 
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) 
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:534) 
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:357) 
at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:167) 
at org.eclipse.jetty.maven.plugin.JettyStartMojo.execute(JettyStartMojo.java:48) 
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) 
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) 
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) 
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347) 
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154) 
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582) 
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) 
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 

我注意到Spring Security 4.0.3.RELEASE依賴於Spring 4.2.2.RELEASE(我的舊版本)。這是否會導致問題?

回答

1

像@Marcinek建議這是春天的一個已知問題。我確實設法進一步縮小了比例,並且春季隊有fixed the problem as well

無論如何,這個問題已經在2.3.0版本中解決了。

我注意到堆棧跟蹤,你正在使用一個非常舊的版本的springfox(以前是swagger-springmvc)。可能值得升級到最新版本,因爲1.x版本和之前版本將不再受支持。最新版本也支持3.2.x版本的spring。另外,如果您在工具方面對swagger 1.2有任何投資,那麼springfox庫也支持該規範的版本。

更多信息可在updated documentation

相關問題