spring boot jar 启出错: Exception in thread main java.lang.ClassNotFoundException
非原创 ren_xian 发表于:2021-12-05 15:30:59
  阅读 :232   收藏   编辑
启动命令:
java -jar app.jar
错误信息:
Exception in thread "main" java.lang.ClassNotFoundException: >com.alibb.web.
bg.AppApplication
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(Laun
chedURLClassLoader.java:94)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner
.java:46)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)
解决办法

pom.xml中build标签中新增

<plugin>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-maven-plugin</artifactId>
	<version>1.4.2.RELEASE</version>
	<configuration>
	    <mainClass>指定你的启动类</mainClass>
	</configuration>
    </plugin>
    <plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-resources-plugin</artifactId>
	<configuration>
	    <encoding>UTF-8</encoding>
	    <useDefaultDelimiters>true</useDefaultDelimiters>
	</configuration>
    </plugin>