SpringBoot项目eclipse运行正常maven install打包启动后报错ClassNotFoundException
parent的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>
SpringBoot项目eclipse运行正常maven install打包启动后报错ClassNotFoundException的更多相关文章
- Maven依赖中的scope详解,在eclipse里面用maven install可以编程成功,到服务器上用命令执行报VM crash错误
Maven依赖中的scope详解 项目中用了<scope>test</scope>在eclipse里面用maven install可以编译成功,到服务器上用命令执行报VM cr ...
- Eclipse中配置Maven build打包
Eclipse中配置Maven build打包 clean package
- maven -- 问题解决(一)解决eclipse中maven项目配置过程和maven install时出现的问题
问题一: 配置项目时出现的错误: error: Cannot change version of project facet Dynamic Web Module to 2.5. error: One ...
- springboot项目部署运行(后台);端口被占用;
打包: mvn clean package -Pprod -Dmaven.test.skip=true -Pprod 使用生产环境配置: -DskipTests,不执行测试用例,但编译测试用例类生成相 ...
- SpringBoot-(1)-IDEA创建SpringBoot项目并运行访问接口
一,安装IDEA mac安装IDEA IDEA配置Tomcat 二,创建SpringBoot项目 1,打开IDEA,点击Create New Project 2,选择自己所安装的JDK.如果没有配置J ...
- SpringBoot项目的几种创建方式,启动、和访问
最常用的4种方式,但除了这些以外,还有其他方式: ①在线创建 ②STS构建 ③Intell Idea内置构建工具 ④Maven创建 STS官网:https://start.spring.io .S ...
- SpringBoot从Eclipse添加的Tomcat容器中启动
SpringBoot的Web项目,想要在Eclipse中的Tomcat容器中启动运行需要做下面这两处改动 pom.xml <packaging>war</packaging> ...
- 排除maven jar冲突 maven tomcat插件启动报错 filter转换异常
最近在搞一个ssm+shiro的整合 用的maven tomcat插件 启动的时候报错,提示 maven org.springframework.web.filter.CharacterEncodin ...
- 解决eclipse用maven install打包报错问题:-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match.
1.添加M2_HOME的环境变量 2.Preference->Java->Installed JREs->Edit 选择一个jdk, 添加 -Dmaven.multiModuleP ...
随机推荐
- linux kernel系列四:嵌入式系统中的文件系统以及MTD
本节介绍File System和MTD技术 一 FS 熟知的FS有ext2,3,4.但是这些都是针对磁盘设备的.而ES中一般的存储设备为Flash,由于Flash的特殊性: Flash存储按照Bloc ...
- PHP构造函数的重载
由于PHP是弱类型语言,因此函数的输入参数类型无法确定(可以使用类型暗示,但是类型暗示无法用在诸如整型,字符串之类的标量类型上),并且对于一个函数,比如只定义了3个输入参数,PHP却运行调用的时候输入 ...
- OpenGL ES 3.0之顶点缓冲
所谓顶点缓冲就是直接将顶点数据存储在gpu的一段缓冲区,不需要从cpu拷贝到gpu.提高了程序的运行效率. 操作步骤 1.创建顶点缓冲对象 GLuint vertexBufferID; 2.分配空间 ...
- 如何让Fiddler可以抓取https的请求
转自:https://jingyan.baidu.com/article/00a07f38bb4f4682d028dcd2.html Fiddler通过在本机开启了一个http的代理服务器来进行htt ...
- (纪录片)电的故事 Shock & Awe The Story of Electricity
简介: 导演: Tim Usborne主演: Jim Al-Khalili类型: 纪录片 / 传记 / 历史官方网站: www.bbc.co.uk/programmes/p00kjq6d制片国家/地区 ...
- jquery.cookie.js结合asp.net实现最近浏览记录
一.html代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww ...
- ZH奶酪:ionic+angularJS+cordova(FileTransfer)上传图片【移动端】
[功能介绍] 在开发应用的时候,经常会遇到需要上传图片的功能,比如修改个人资料的头像.本文介绍的是基于ionic框架,在移动端上传图片的功能. [功能流程] (1)点击页面上的头像,弹出一个对话框,选 ...
- NetCore的控制台应用中搭建WebServer的方法
一.新建NetCore控制台项目,并引入下列Nuget包: Microsoft.AspNetCore.StaticFiles.Microsoft.AspNetCore.Http.Microsoft.A ...
- POJ2429_GCD & LCM Inverse【Miller Rabin素数測试】【Pollar Rho整数分解】
GCD & LCM Inverse Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9756Accepted: 1819 ...
- 算法笔记_222:串中取3个不重复字母(Java)
目录 1 问题描述 2 解决方案 1 问题描述 从标准输入读入一个由字母构成的串(不大于30个字符). 从该串中取出3个不重复的字符,求所有的取法. 取出的字符,要求按字母升序排列成一个串. 不同 ...