一、问题描述:

  项目分多个模块,open-eureka注册中心、open-provider服务提供者、open-common公共部分,provider依赖common。父pom使用spring-boot-maver-plugin插件,项目直接运行Main主类没问题,但是install报common中的类找不到符号.

二、查找问题:

  spring-boot-maven-plugin 打包跟普通的apache-maven-plugin打包不一致,前者打的jar 包是可以直接用java -jar  name.jar 来执行的,但是common模块只是作为一个其他模块的依赖来使用,并不需要有启动类,也不需要执行。

三、解决办法:

 3.1、删除父pom中的spring-boot-maven-plugin插件依赖,父pom不需要<build>

parent.pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.starfast.open</groupId>
<artifactId>starfast-open</artifactId>
<version>0.0.1-SNAPSHOT</version>
<modules>
<module>open-eureka</module>
<module>open-provider</module>
<module>open-feign</module>
<module>open-common</module>
</modules>
<packaging>pom</packaging> <name>starfast-open</name> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
<witown.open.version>1.0-SNAPSHOT</witown.open.version>
<open.common.version>0.0.1-SNAPSHOT</open.common.version>
</properties> <dependencies> <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency>
</dependencies> <dependencyManagement>
<!--引入spring-cloud依赖-->
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency> <dependency>
<groupId>com.witown.app</groupId>
<artifactId>open-sdk</artifactId>
<version>${witown.open.version}</version>
</dependency> <dependency>
<groupId>com.starfast.open</groupId>
<artifactId>open-common</artifactId>
<version>${open.common.version}</version>
</dependency>
</dependencies>
</dependencyManagement> </project>

 3.2、只在需要独立运行的模块,如provider模块中加载spring-boot-maven-plugin插件依赖

provider.pom

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>starfast-open</artifactId>
<groupId>com.starfast.open</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>open-provider</artifactId>
<name>open-provider</name> <dependencies>
<!--common模块-->
<dependency>
<groupId>com.starfast.open</groupId>
<artifactId>open-common</artifactId>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

3.3、删除不需要独立运行的模块中的spring-boot-maven-plugin插件依赖

common.pom

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>starfast-open</artifactId>
<groupId>com.starfast.open</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>open-common</artifactId>
<packaging>jar</packaging>
<name>open-common</name> <dependencies>
<!--web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--eureka client-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!--redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> <!--开放平台-->
<dependency>
<groupId>com.witown.app</groupId>
<artifactId>open-sdk</artifactId>
</dependency>
<!--监控-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--单元测试-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies> </project>

install结果:

顺便吐槽,网上的垃圾文章真多,还好发现了该篇文章,

https://blog.csdn.net/SnailMann/article/details/81710461

多谢作者。

spring-boot-maven-plugin多模块install问题解决办法的更多相关文章

  1. Spring Boot Maven Plugin(一):repackage目标

    简介 Spring Boot Maven Plugin插件提供spring boot在maven中的支持.允许你打包可运行的jar包或war包. 插件提供了几个maven目标和Spring Boot ...

  2. Spring Boot Maven Plugin打包异常及三种解决方法:Unable to find main class

    [背景]spring-boot项目,打包成可执行jar,项目内有两个带有main方法的类并且都使用了@SpringBootApplication注解(或者另一种情形:你有两个main方法并且所在类都没 ...

  3. Spring Boot Maven Plugin(二):run目标

    简介 Spring Boot Maven Plugin插件提供spring boot在maven中的支持.允许你打包可运行的jar包或war包. 插件提供了几个maven目标和Spring Boot ...

  4. Spring Boot的Maven插件Spring Boot Maven plugin详解

    Spring Boot的Maven插件(Spring Boot Maven plugin)能够以Maven的方式为应用提供Spring Boot的支持,即为Spring Boot应用提供了执行Mave ...

  5. 微服务下 Spring Boot Maven 工程依赖关系管理

    单体 Spring Boot Maven 工程 最基本的 pom.xml 包含工程信息.Spring Boot 父工程.属性配置.依赖包.构建插件 <?xml version="1.0 ...

  6. spring boot 配置访问其他模块包中的mapper和xml

    maven项目结构如下,这里只是简单测试demo,使用的springboot版本为2.1.3.RELEASE 1.comm模块主要是一些mybatis的mapper接口和对应的xml文件,以及数据库表 ...

  7. Spring Boot源码中模块详解

    Spring Boot源码中模块详解 一.源码 spring boot2.1版本源码地址:https://github.com/spring-projects/spring-boot/tree/2.1 ...

  8. spring boot & maven 多模块 ---心得

    1.前言 有个名字叫 多模块企业级项目  ,其实就是一个父级maven工程里面有着多个子级maven工程的项目 ,甚至在子级maven 里面还有多个子级maven, 这用到了 maven多模块开发的使 ...

  9. spring boot maven打包可运行jar包

    普通打包之后在程序目录运行,或者编写bat运行时会提示“没有主清单属性”,这是因为并没有找到main()方法,需要我们指明告诉java程序 我bat中的代码 @echo off title mytit ...

随机推荐

  1. 集群监控之 —— ipmi操作指南

    http://blog.csdn.net/yunsongice/article/details/5408802 智能平台管理界面(IPMI,Intelligent Platform Managemen ...

  2. 浅析JavaScript访问对象属性和方法及区别

    属性是一个变量,用来表示一个对象的特征,如颜色.大小.重量等:方法是一个函数,用来表示对象的操作,如奔跑.呼吸.跳跃等. 在JavaScript中通常使用”."运算符来存取对象的属性的值.或 ...

  3. HTTP Cookie 详解

    参考: http://blog.csdn.net/lijing198997/article/details/22174151

  4. PHP安装memcache扩展

    1.下载memcache.dll扩展 http://pecl.php.net/package/memcache/3.0.8/windows .下载完成之后, 将其中的php_memcache.dll ...

  5. Java程序设计17——多线程-Part-B

    5 改变线程优先级 每个线程执行都具有一定的优先级,优先级高的线程获得较多的执行机会,而优先级低的线程则获得较少的执行机会. 每个线程默认的优先级都与创建它的父线程具有相同的优先级,在默认情况下,ma ...

  6. IntelliJ IDEA版本控制——过滤提交文件

    File——>Settings——>File Types 在ignore files and folders中添加提交是需要忽略的文件 例如:*.iml;*.idea;*.gitignor ...

  7. IP转换成域名

    DNS就是域名解析系统,它可以将IP转换成域名,也可以将域名转换成IP 1. 安装DNS服务 开始—〉设置—〉控制面板—〉添加/删除程序—〉添加/删除Windows组件—〉“网络服务”—〉选择“域名服 ...

  8. Oracle学习笔记(九)

    十二.PL/SQL 1.PL/SQL程序的结构和组成 示例:给员工涨工资(根据职位涨工资) 总裁涨1000 经理涨800 其他员工涨400 学习原因:1.操作数据库效率最高 2.为了后期的存储过程的学 ...

  9. RECONSUME_LATER

    Failure consumption,later try to consume. ================MessageExt [queueId=0, storeSize=134, queu ...

  10. 服务器如何打开ping命令

    服务器禁止ping后忘记是用什么方法禁止的了.只知道不是使用ip策略现在需要再开启ping...请问该怎么弄? 是不是windows防火墙开启了啊,到控制面板里的windows防火墙中看看,把防火墙关 ...