SpringBoot项目eclipse运行正常maven install打包启动后报错ClassNotFoundException
2017-11-03 14:44
926 查看
parent的pom.xml
直接在IDEA里面运行SpringBoot启动类是可以正常访问的,但是使用
其中,Springboot启动包是rest包,当中引用了service包中的User类,在打包之后的rest.jar里面lib目录下有service.jar,但是一访问就找不到类
解决方法:要给被依赖的module的pom.xml中添加
<groupId>cn.licoy</groupId> <artifactId>parent</artifactId> <version>0.1</version> <packaging>pom</packaging> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.6.RELEASE</version> </parent> <modules> <module>../rest</module> <module>../service</module> </modules> <dependencies> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.16</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>cn.licoy.rest.RestApplication</mainClass> <layout>ZIP</layout> </configuration> <executions> <execution> <goals> <goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中--> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
直接在IDEA里面运行SpringBoot启动类是可以正常访问的,但是使用
mvn install打包后,报出如下错误:
java.lang.ClassNotFoundException: cn.licoy.service.entity.User at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_131] at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_131] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[rest-0.1.jar:0.1]
其中,Springboot启动包是rest包,当中引用了service包中的User类,在打包之后的rest.jar里面lib目录下有service.jar,但是一访问就找不到类
解决方法:要给被依赖的module的pom.xml中添加
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <classifier>exec</classifier> </configuration> </plugin> </plugins> </build>
相关文章推荐
- Maven项目Eclipse启动时报错: java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener
- Maven项目Eclipse启动时报错: java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener
- eclipse maven+mybatis+spring+springmvc 项目启动报错:java.lang.ClassNotFoundException: org.aspectj.weaver.r
- maven项目 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- maven项目在eclipse启动报错:java.lang.ClassNotFoundException
- maven项目运行报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- eclipse使用maven,启动工程tomcat报错:java.lang.ClassNotFoundException: org.springframework.web.context.Contex
- 【项目启动】 tomcat启动,项目无法启动,无法正常访问/项目可以启动,报错:java.lang.ClassNotFoundException: ContextLoaderListener
- maven项目 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- maven项目 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- maven创建spring项目之后,启动报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoade
- tomcat启动spring boot项目报错:java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
- eclipse创建第一个spring boot工程项目时ClassNotFoundException
- maven项目启动报错: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- Maven工程启动报错:maven 项目出现 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoad
- Eclipse使用Maven构建项目运行main方法报ClassNotFoundException
- Maven项目下update maven后Eclipse报错:java.lang.ClassNotFoundException: org.springframework.web.context.Con
- maven项目 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- myeclipse启动maven项目报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoader
- maven项目 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener