【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>
相关推荐
数智启示录16 小时前
实时数据湖 Flink CDC + Kafka +Doris 【企业级实战】之Kafka 事件缓冲层 【附核心源码】 04
java·大数据·flink·kafka·数据库开发
AI人工智能+电脑小能手16 小时前
大白话说Java设计模式-41-备忘录模式(源码剖析篇)
java·设计模式·备忘录模式·源码分析·serializable·undo log·spring statemachine
lv__pf16 小时前
Sentinel【TL微服务10、11】
java·微服务·sentinel
Escalating_xu16 小时前
【C++ string 上篇】从字符串基础到容量管理、迭代器与经典算法题
java·c++·算法
曹牧17 小时前
Java:Java 数组转 List
java·开发语言·windows
MetaLite17 小时前
Spring-MVC微服务接口怎么分层-网关Controller与Service边界
spring·微服务·mvc
下辈子不要当码农17 小时前
Day7-Linux软件编程(进程与线程(3))
java·开发语言
深入云栈17 小时前
一文搞懂Netty 4.2六大核心概念:Channel/EventLoop/Selector/ByteBuf 如何关联
java·后端
大模型码小白17 小时前
Spring AI 框架中集成 MCP 的完整指南:从服务端到客户端的全流程实践
大数据·运维·数据库·人工智能·python·sql·spring
hh95017 小时前
Agent Plan × DeepSeek Harness:角色 Prompt 驱动的 Agent 分工优化与协作质量实验
java·前端·人工智能·prompt·adg·agent plan·adg成都社区