[英]Application failed to start with classpath:
我有一個關於應用程序無法啟動類路徑的問題。 我正在使用springboot版本1.5.10,我試圖在jboss上作為一個獨立的jar部署。 我得到以下classNotFound
java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/source/ConfigurationPropertySources
at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.getFirstNonLoopbackHostInfo(HostInfoEnvironmentPostProcessor.java:46)
at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.postProcessEnvironment(HostInfoEnvironmentPostProcessor.java:35)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
2019-03-26 17:35:33,919 DEBUG [o.s.b.l.ClasspathLoggingApplicationListener] [main] Application failed to start with classpath: [file:/C:/Program%20Files%20(x86)/Java/jdk1.8.0_60/jre/lib/resources.jar, file:/C:/Program%20Files%20(x86)/Java/jdk1.8.0_60/jre/lib/rt.jar, file:/C:/Program%20Files%20(x86)/Java/jdk1.8.0_60/jre/lib/jsse.jar, file:/C:/Program%20Files%20(x86)/Java/jdk1.8.0_60/jre/lib/jce.jar, file:/C:/Program%20Files%20(x86)/Java/jdk1.8.0_60/jre/lib/charsets.jar, file:/C:/Program%20Files%20(x86)/Java/jdk1.8.0_60/jre/lib/jfr.jar, file:/C:/Program%20Files%20(x86)/Java/jdk1.8.0_60/jre/lib/ext/access-bridge-32.jar,
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.source.ConfigurationPropertySources
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 27 common frames omitted
我可以看到spring-context存在於我的maven依賴項中,我仍然看到NoClassDefFoundError,如上所示,請查找下面是我的pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
<version>${consul-starter.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-consul-dependencies</artifactId>
<version>${cloud-consul.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-version}</version>
<scope>${dep.scope}</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
<scope>${dep.scope}</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.2.1.GA</version>
</dependency>
<!-- JAXB support -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>2.2.1.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<version>2.2.1.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>2.2.1.GA</version>
</dependency>
<dependency>
<groupId>org.kie.remote</groupId>
<artifactId>kie-remote-client</artifactId>
<version>${version.org.kie}</version>
<!-- <version>6.5.0.Final</version> -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kie.server</groupId>
<artifactId>kie-server-client</artifactId>
<version>${version.org.kie}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${version.org.kie}</version>
<!-- <version>6.5.0.Final-redhat-17</version> -->
</dependency>
<dependency>
<groupId>org.kie.server</groupId>
<artifactId>kie-server-api</artifactId>
<version>${version.org.kie}</version>
<!-- <version>6.5.0.Final</version> -->
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
<consul-starter.version>1.3.0.RELEASE</consul-starter.version>
<cloud-consul.version>1.3.0.RELEASE</cloud-consul.version>
<dep.scope>compile</dep.scope>
<springfox-version>2.5.0</springfox-version>
<!-- <version.org.kie>6.5.0.Final-redhat-16</version.org.kie> -->
<version.org.kie>6.5.0.Final-redhat-17</version.org.kie>
</properties>
有人可以幫我解決這個問題。 感謝您的幫助。
您指出的錯誤是“ ConfigurationPropertySources Missing。
如果對Cofig文件進行任何更改,則必須始終再次構建Cofig文件。
只需前往配置文件所在的文件夾即可。
Shift+Right_Click
gradle gAC
現在再次構建您的項目,即DTO( 如果有 )*和所有其他Java文件,現在您的程序應該正常運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.