在我的Maven项目中运行以下 class
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。释放我的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>
最佳答案
从4.0开始提供此类。看这里
Class DefaultParameterNameDiscoverer
您应该将 spring-core 工件升级到4.0版本。
关于java - 线程“main”中的Maven项目异常java.lang.NoClassDefFoundError:org/springframework/core/DefaultParameterNameDiscoverer,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25642845/