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. Android利用RecognizerIntent识别语音并简单实现打电话动作

    关于Android利用RecognizerIntent识别语音并简单实现打电话,详细看实现代码例如以下: package com.example.recognizerintentactivity; i ...

  2. Android 多屏适配解决方式

    1.主流手机必要測量的參数(通过详细的方法.測量出,须要測试手机的 以下的这些參数,我们主要使用的仅仅是 screenwidth  这个參数,其它參数仅仅是帮助我们更好的理解 屏幕适配) Displa ...

  3. LNMP(Linux+Nginx+MySQL+PHP)centos6.4安装

    nginx命令 停止nginx服务:# /etc/init.d/nginx stop 启动nginx服务:# /etc/init.d/nginx start 编辑nginx配置文件:# vim /et ...

  4. ZH奶酪:Python中zip函数的使用方法

    定义:zip([iterable, …]) zip()是Python的一个内建函数,它接受一系列可迭代的对象作为参数,将对象中对应的元素打包成一个个tuple(元组),然后返回由这些 tuples组成 ...

  5. WinForm 之 自定义标题栏的窗体移动

    通过标题栏的鼠标事件实现窗体移动,代码如下: bool m_isMouseDown = false; //窗体是否移动 Point m_mousePos; //记录窗体的位置 /// <summ ...

  6. Yahoo邮箱最后登录,成为历史!

  7. 数据库同步相关的SQL语句

    一.目标: 本文重点给大家介绍几款SQL用法,一般常用于数据库同步之类的. 二.例子: 1.找出A表中不存在于B表的记录. from B where A.[序号]=B.[序号]); 2.将A表中不存在 ...

  8. 低危漏洞- X-Frame-Options Header未配置

    原文链接:https://developer.mozilla.org/zh-CN/docs/Web/HTTP/X-Frame-Options?redirectlocale=en-US&redi ...

  9. …… are only available on JDK 1.5 and higher 错误

    "C:\Program Files\Java\jdk1.8.0_73\bin\java" -ea -Didea.test.cyclic.buffer.size=1048576 &q ...

  10. Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'系列三:重置主从同步

    1:停止slave服务器的主从同步 stop slave; 2:对Master数据库加锁 flush tables with read lock; 3:备份Master上的数据 mysqldump - ...