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>
相关推荐
花开富贵ii1 小时前
代码随想录算法训练营四十三天|图论part01
java·数据结构·算法·深度优先·图论
布朗克1682 小时前
Java 10 新特性及具体应用
java·开发语言·新特性·java10
ZZHow10245 小时前
JavaWeb开发_Day05
java·笔记·web
CHEN5_025 小时前
【Java虚拟机】垃圾回收机制
java·开发语言·jvm
Warren985 小时前
Lua 脚本在 Redis 中的应用
java·前端·网络·vue.js·redis·junit·lua
艾伦~耶格尔9 小时前
【数据结构进阶】
java·开发语言·数据结构·学习·面试
爪洼传承人9 小时前
18- 网络编程
java·网络编程
smileNicky9 小时前
SpringBoot系列之从繁琐配置到一键启动之旅
java·spring boot·后端
祈祷苍天赐我java之术10 小时前
Java 迭代器(Iterator)详解
java·开发语言
David爱编程10 小时前
为什么必须学并发编程?一文带你看懂从单线程到多线程的演进史
java·后端