在运行时找不到Spring开发工具类



我创建了一个SpringBoot应用程序,该应用程序在Maven pom 中有spring-boot开发工具

我可以在Intellji中毫无问题地运行它。但是,如果我从正在构建的jar中运行它,它会抛出以下异常。它给出了以下例外情况。看起来devtool jar没有打包?!

org.springframework.beans.factory.BeanDefinitionStoreException:无法解析配置类[com.x.x.x.TestApplication];嵌套异常是java.io.FileNotFoundException:类路径资源[org/springframework/boot/devtools/filewatch/FileChangeListener.class]无法打开,因为它不存在

默认情况下,Devtools从打包的jar中排除,以避免在生产部署中意外使用。如果你想在你的包装罐中包含Devtools,你可以选择加入。为此,请在插件配置中将excludeDevtools设置为false

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludeDevtools>false</excludeDevtools>
</configuration>
</plugin>
</plugins>
</build>

最新更新