【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>
相关推荐
silvamux_15 分钟前
微头条爆款体平台适配实测:把交付要求变成可计算的指标
java·线性代数·算法·决策树·矩阵
论文复现现场16 分钟前
DeepSeek V4.1 Flash 和 V4 Pro 有什么区别?API 价格、性能与迁移建议
java·服务器·人工智能·python·大模型api·deepseek·deepseek v4.1
郭小李1 小时前
转发与重定向
java·服务器·数据库
你看我名字1 小时前
数眼智能 Search + Reader 实战:联网问答怎样避免“搜到了,却引用错了”
android·java·开发语言
MetaLite1 小时前
Spring Boot 加了 @Valid,嵌套参数为什么还没校验?
java·spring boot·后端
半杯咖啡半行码1 小时前
QML与 Qt Quick入门实战:从零基础到 C++ 双向通信详解
java·qt·交互
霸道流氓气质1 小时前
Lingua 语言检测库:n-gram 统计模型、置信度阈值调优与 Spring Boot 分层检测管道的生产级实战
java·spring boot·后端
霸道流氓气质1 小时前
智能表单生成器:结构化输出契约、JSON Schema 驱动渲染与 EAV/JSONB 混合存储的 Vue3 + Spring AI 生产级实战
人工智能·spring·json
文丑颜不良啊1 小时前
LeetCode1281~1300题目解析
java·leetcode
missile1112 小时前
# HDR 算法 ISP 通路客制化方案(G100 / mt6789)
java·前端·javascript