问题描述
我有一个使用 maven
和 spring mvc
和 tomcat7-maven-构建的应用程序插件
。我可以将这些打包到jar文件中,以便我可以运行jar文件来启动tomcat服务器吗?
这意味着我不需要tomcat,只有jar文件可以提供Web服务。
Spring文档是你的朋友。我提供了您可以关注的链接,以及本文中突出显示的部分。
一次spring-boot-maven-plugin已经包含在你的 pom.xml
中,它会自动尝试使用 spring-boot重写存档以使它们可执行:重新包装
目标。您应该使用 pom.xml中的常用包装元素来配置项目以构建jar或war(视情况而定)
您要启动的主类可以使用配置选项指定,也可以通过以常规方式向清单添加 Main-Class
属性。 / p>
要构建和运行项目工件,您可以输入以下内容:
$ mvn package
$ java -jar target / mymodule-0.0.1-SNAPSHOT.jar
有关该插件的更多信息,请访问
I have an application built using maven
and spring mvc
and tomcat7-maven-plugin
. Can I package these to a jar file, so that i can run the jar file to start a tomcat server?
That means i don't need tomcat, only a jar file can provide a web service.
Spring documentation is your friend. I am providing the links which you can follow, with highlighted parts in this post.
Once spring-boot-maven-plugin has been included in your pom.xml
it will automatically attempt to rewrite archives to make them executable using the spring-boot:repackage
goal. You should configure your project to build a jar or war (as appropriate) using the usual packaging element in the pom.xml
The main class that you want to launch can either be specified using a configuration option, or by adding a Main-Class
attribute to the manifest in the usual way.
To build and run a project artifact, you can type the following:
$ mvn package
$ java -jar target/mymodule-0.0.1-SNAPSHOT.jar
More information about the plugin is available here
这篇关于我如何将spring mvc应用程序打包到jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!