Maven项目线程中的异常" main" java.lang.NoClassDefFoundError:org / springframework / core / DefaultParameterNameDiscoverer

时间:2014-09-03 11:11:14

标签: java spring maven

我在Maven项目中运行以下课程

package com.zra.test;

import javax.xml.ws.Endpoint;

import com.zra.proxy.NickGateway;

public class ProxyPublisher {
public static void main(String args[]){
    try {
        System.out.println("Publishing ProxyService at http://localhost:8280/ZRAProxy/ZRAProxy...");
        Endpoint.publish("http://localhost:8280/ZRAProxy/ZRAProxy", new NickGateway());
        System.out.println("Proxy service successfully published on http://localhost:8280/ZRAProxy/ZRAProxy");
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Exception publishing webservice");
      }
   }
}

我想测试我的应用程序,但我收到以下错误

    Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/DefaultParameterNameDiscoverer
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:123)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:170)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.<init>(DefaultListableBeanFactory.java:170)
       at org.springframework.context.support.AbstractRefreshableApplicationContext.createBeanFactory(AbstractRefreshableApplicationContext.java:195)
  at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:148)
       at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:122)
       at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:94)
       at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:83)
       at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:106)
       at org.apache.cxf.BusFactory.createThreadBus(BusFactory.java:243)
       at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:227)
       at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:214)
       at org.apache.cxf.jaxws.spi.ProviderImpl.createEndpoint(ProviderImpl.java:131)
       at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:154)
       at javax.xml.ws.Endpoint.publish(Endpoint.java:240)
       at com.zra.test.ProxyPublisher.main(ProxyPublisher.java:11)
    Caused by: java.lang.ClassNotFoundException: org.springframework.core.DefaultParameterNameDiscoverer
       at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
       at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
       ... 24 more

这是我的依赖项,我已将我的依赖项更改为3.1.3.RELEASE我的pom.xml中出现错误

      <repository>
    <id>spring-snapshots</id>
    <name>Spring Maven Snapshot Repository</name>
    <url>http://s3.amazonaws.com/maven.springframework.org/snapshot</url>
  </repository>
  </repositories>

  <properties>
  <spring.version>3.1.3.RELEASE</spring.version>
  <spring-batch.version>2.1.9.RELEASE</spring-batch.version> 
  </properties>

  <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.1.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.1.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.0.2.RELEASE</version>
        </dependency>
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
            <version>4.0.2.RELEASE</version>
        </dependency>

2 个答案:

答案 0 :(得分:7)

这个课程从4.0开始提供。看看这里

Class DefaultParameterNameDiscoverer

您应该将 spring-core 工件升级到4.0版本。

答案 1 :(得分:0)

您有一些版本3.1.3.RELEASE的春天依赖项和一些4.0.2.RELEASE。尝试使用相同版本的依赖项。我猜测Spring依赖项的混合版本会导致问题。

阅读spring reference documents中的Maven "Bill Of Materials" Dependency部分。