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>
相关推荐
AI人工智能+电脑小能手1 小时前
大白话说Java设计模式-08-建造者模式(业务实战篇)
java·设计模式·建造者模式·架构设计·对象构建
xbgRS1 小时前
java中的线程
java
今天的砖头有点烫手啊1 小时前
接口太慢?Spring Boot 缓存体系 @Cacheable 全链路拆解
spring boot·后端·缓存
ChaHae-In2 小时前
MyBatis入门操作
java·mybatis
xcLeigh2 小时前
Go入门:短变量声明的陷阱与最佳实践
java·redis·golang·教程·变量
青山木2 小时前
Hot 100 --- 最小栈
java·数据结构·算法·leetcode
疯狂打码的少年2 小时前
【数据结构】栈的应用:表达式求值(后缀表达式)
java·数据结构·笔记·算法
szephyr2 小时前
腾讯云 ADP 智能体的 Skills 版本回滚总是回到旧配置,是缓存没清还是版本管理没开?
java·缓存·腾讯云
云烟成雨TD2 小时前
Micrometer 系列【39】链路追踪:入门案例 | 环境准备
java·云原生·链路追踪
chuan.bai2 小时前
Java RAG 实战(第 3 篇):从交互式聊天到多轮上下文
java·人工智能·macos·ai