【Java-Maven】打包配置 支持非spring应用

未完待续...

非Spring应用打包方式-整个包

有时候需要启动一些小服务(类似脚本, 处理完结束任务).

可能这时候, 不会再用SpringBoot那么大费周章. 所以就需要用'main'方法启动服务了.

如何指定'主类', 并将外部引用的依赖一齐打入jar包呢? 可参考下面的pom.xml中的<build/>片段:

xml 复制代码
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>xxx.xxx.MainClassName</mainClass>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>.</Class-Path>
                    </manifestEntries>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- bind to the packaging phase -->
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
相关推荐
IT枫斗者枫哥1 分钟前
Java 接口超时后,重试为什么会多建一条任务?
java
用户3126874877206 分钟前
CAS 到底是怎么保证原子性的?从 Unsafe 到 VarHandle 的演进
java
Zane199411 分钟前
线上突然OOM,你的排查顺序是先看日志还是先重启
java·后端
君顾123 分钟前
折扣卡 CPS 小程序定制:从业务流程到系统架构的实践指南
java·开发语言·折扣卡
见不散25 分钟前
GPT-5.6 Luna (Batch) 批量处理能力深度评测
java·gpt·batch
计算机毕设定制辅导-无忧学长43 分钟前
《基于SpringBoot的庭院玫瑰栽培养护知识交互式科普平台设计与实现》
java·spring boot·后端·毕业设计·个性化推荐·协同过滤算法·庭院玫瑰栽培养护知识科普平台
大模型码小白1 小时前
Harness Engineering 驾驭工程:从使用到项目实战
大数据·数据库·人工智能·python·spring
Json____1 小时前
从零构建家政服务平台:一套全栈架构如何打通管理端与移动端-java-springboot
java·spring boot·后端·架构·毕设·wwwoop.com
云雀衔光2 小时前
Java Spring AI MCP:在 Spring 里把 AI 接上你的业务系统
java·开发语言·人工智能·后端·测试工具·spring
重生之小比特2 小时前
【Java SE】数据类型与变量
java·开发语言·python