【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>
相关推荐
代码AI弗森2 小时前
一文理清楚“算力申请 / 成本测算 / 并发评估”
java·服务器·数据库
Old Uncle Tom3 小时前
OpenClaw 记忆系统 -- 记忆预加载
java·数据结构·算法·agent
小小小米粒3 小时前
Collection单列集合、Map(Key - Value)双列集合,多继承实现。
java·开发语言·windows
摇滚侠3 小时前
expdp 查看帮助
java·数据库·oracle
:1214 小时前
java基础
java·开发语言
曹牧5 小时前
Spring:@RequestMapping注解,匹配的顺序与上下文无关
java·后端·spring
daixin88485 小时前
cursor无法正常使用gpt5.5等模型解决方案
java·redis·cursor
韦禾水6 小时前
记录一次项目部署到tomcat的异常
java·tomcat
曦月合一6 小时前
树莓派安装jdk、tomcat、vnc、谷歌浏览器开机自启等环境配置
java·tomcat·树莓派
此剑之势丶愈斩愈烈6 小时前
openssl 自建证书
java