Maven - no main manifest attribute(SpringBoot 多模块)

问题描述

no main manifest attribute

解决方案

一个主项目下,多个业务模块,假设 starter 模块作为启动器,以及主项目(project)最外层父 pom.xml

  • 最关键要关注这 2 个 pom.xml(starter - pom.xml & project - pom.xml)
html 复制代码
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <includeSystemScope>true</includeSystemScope>
            </configuration>
        </plugin>
    </plugins>
</build>

其实 starter - pom.xml 写上这个就亲测有效,如何验证呢?!

  • 查看上面图片上文件 MANIFEST.MF,有出现 Main-Class、Start-Class 说明稳了~
bash 复制代码
Manifest-Version: 1.0
Implementation-Title: szqy-starter
Implementation-Version: 0.0.1-SNAPSHOT
Start-Class: com.szqy.starter.SzqyStarterApplication
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Build-Jdk-Spec: 1.8
Spring-Boot-Version: 2.1.18.RELEASE
Created-By: Maven Archiver 3.4.0
Main-Class: org.springframework.boot.loader.JarLauncher

但是为什么还要在 project - pom.xml 加插件,是因为这项目用了 mapstruct,需要对它和 lombok 做一些处理。当然如果没这个需求,我觉得可以不用加这段,理论上也可以启动成功!

html 复制代码
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>8</source>
                <target>8</target>
                <encoding>UTF-8</encoding>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>1.4.1.Final</version>
                    </path>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>1.18.12</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>
相关推荐
小bo波4 小时前
Java Swing 图形用户界面实验 —— 从算术练习到游戏开发的完整实践
java·课程设计·gui·游戏开发·扫雷·swing
咖啡八杯5 小时前
GoF设计模式——备忘录模式
java·后端·spring·设计模式
SamDeepThinking16 小时前
裁掉那个差程序员后,给你看团队里高手的代码:这个习惯,希望你有
java·后端·程序员
朕瞧着你甚好17 小时前
技术雷达 & Java 集成评估报告 — Apache Tika 3.3.1
java·ai编程
MacroZheng18 小时前
短短几天,暴涨2.8万Star!又一款编程神器开源!
java·人工智能·后端
SamDeepThinking18 小时前
函数式编程:用BiFunction消除多类型分支的代码重复
java·后端·面试
Flittly1 天前
【AgentScope Java新手村系列】(16)从RAG到多路检索
java·spring boot·spring
小兔崽子去哪了1 天前
Java 生成二维码解决方案
java·后端
人活一口气2 天前
从JVM调优到MCP协议:Java全栈技术体系深度总结与企业级架构实践
java·spring boot
NE_STOP2 天前
Vibe Coding -- 完整项目案例实操
java