【IDEA】搭建聚合项目抛Unable to find main class

背景

项目是springboot,分多模块:common公共模块、order订单模块和stock库存模块。
项目在idea运行都没问题,一到maven install之后,common公共模块就抛出Unable to find main class。

在网络上,大部分都说在POM文件中指定mainclass。如:

<?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>lcn-parent</artifactId>
        <groupId>com.springcloud</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>common2</artifactId>

    <!-- Unable to find main class -->
    <properties>
        <start-class>主类路径</start-class>
    </properties>
</project>

但是我在想,这个工程是定义一些常量而已,根本不需要指定mainclass,所以这个不是解决问题的根本方法。

最后查到一篇文章提到spring-boot-maven-plugin 打包跟普通的apache-maven-plugin打包不一致。
https://www.cnblogs.com/geekdc/p/10744903.html

解决方案就是,common公共模块的pom文件中的build节点去掉。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容