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的更多相关文章

  1. Maven依赖中的scope详解,在eclipse里面用maven install可以编程成功,到服务器上用命令执行报VM crash错误

    Maven依赖中的scope详解 项目中用了<scope>test</scope>在eclipse里面用maven install可以编译成功,到服务器上用命令执行报VM cr ...

  2. Eclipse中配置Maven build打包

    Eclipse中配置Maven build打包 clean package

  3. maven -- 问题解决(一)解决eclipse中maven项目配置过程和maven install时出现的问题

    问题一: 配置项目时出现的错误: error: Cannot change version of project facet Dynamic Web Module to 2.5. error: One ...

  4. springboot项目部署运行(后台);端口被占用;

    打包: mvn clean package -Pprod -Dmaven.test.skip=true -Pprod 使用生产环境配置: -DskipTests,不执行测试用例,但编译测试用例类生成相 ...

  5. SpringBoot-(1)-IDEA创建SpringBoot项目并运行访问接口

    一,安装IDEA mac安装IDEA IDEA配置Tomcat 二,创建SpringBoot项目 1,打开IDEA,点击Create New Project 2,选择自己所安装的JDK.如果没有配置J ...

  6. SpringBoot项目的几种创建方式,启动、和访问

    最常用的4种方式,但除了这些以外,还有其他方式: ①在线创建 ②STS构建 ③Intell  Idea内置构建工具 ④Maven创建 STS官网:https://start.spring.io  .S ...

  7. SpringBoot从Eclipse添加的Tomcat容器中启动

    SpringBoot的Web项目,想要在Eclipse中的Tomcat容器中启动运行需要做下面这两处改动 pom.xml <packaging>war</packaging> ...

  8. 排除maven jar冲突 maven tomcat插件启动报错 filter转换异常

    最近在搞一个ssm+shiro的整合 用的maven tomcat插件 启动的时候报错,提示 maven org.springframework.web.filter.CharacterEncodin ...

  9. 解决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 ...

随机推荐

  1. List 集合的交集

    private void Test() { List<string> lsA = new List<string>(); lsA.Add("A"); lsA ...

  2. linux性能分析工具集(图示)

  3. IIS 7.5: HOW TO ENABLE TLS 1.1 AND TLS 1.2

    In IIS 7.5, which is installed on Windows 2008 R2 servers, only SSL 3.0 and TLS 1.0 are enabled for ...

  4. Android 关于操作栏 ActionBar 的设计原则【转载+整理】

    原文地址 本文内容 操作栏目的 基本布局 适应旋转和不同的屏幕尺寸 副操作栏的布局 操作栏按钮 上下文操作栏 操作栏清单 设计原则就是为你在编写 Android APP 时,尤其是如何安排操作按钮的位 ...

  5. Format Conditions按条件显示表格记录

    标记特定记录 DevExpress强大得确实让人觉得它别具一格!现在,我有这样一个需求,把一个表中某字段为False的记录标记出来.下面是效果(某字段的可见性为否): 实现方式 如果是以前,我写个代码 ...

  6. VS2015 之 多行缩进

        VS2015工具栏缺少“多行缩进工具”,经查阅资料总结如下:     首先,选中需要缩进的行代码:     1.增大缩进:“Tab”键     2.减小缩进:“Shift”键 + “Tab”键

  7. 一次性解决Intellij IDEA maven 自动跳到1.5的JDK

    说明:文章学习自:https://blog.csdn.net/Zereao/article/details/77427989 一.找到Setting.xml文件 打开setting.xml 说明,该文 ...

  8. Active Directoty域服务安装

    运行dcpromo命令,打开“Active Directoty域服务安装向导”

  9. JS密码校验规则前台验证(不能连续字符(如123、abc)连续3位或3位以上)(不能相同字符(如111、aaa)连续3位或3位以上)

    密码必须为8到16位且必须包含数字和字母 密码必须包含特殊字符[_&#%] 不能连续字符(如123.abc)连续3位或3位以上 不能相同字符(如111.aaa)连续3位或3位以上 /** * ...

  10. nuxt框架学习

    1.static和assets文件夹区别 相同点:都可以存放静态文件 不同:assets下的文件 webpack会处理:static文件夹下的文件不会处理. 2.middleware middlewa ...