当前位置: 首页 > news >正文

邢台做移动网站/平台交易网

邢台做移动网站,平台交易网,企业大型网站开发网站模板设计,青岛建手机网站哪家好1, 简介 先看官方文档:http://maven.apache.org/plugins/maven-assembly-plugin/index.html maven-assembly-plugin可以将依赖的第三方jar包打包到jar中,这样方便我们发布可执行的jar包。 2, 用法 用法部分的官方文档&#xff…
  • 1, 简介

先看官方文档:http://maven.apache.org/plugins/maven-assembly-plugin/index.html maven-assembly-plugin可以将依赖的第三方jar包打包到jar中,这样方便我们发布可执行的jar包。

  • 2, 用法

用法部分的官方文档:http://maven.apache.org/plugins/maven-assembly-plugin/index.html

      <plugin><artifactId>maven-assembly-plugin</artifactId><version>3.1.0</version><configuration><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>
  • 3,具体示例

具体工程代码在这里。欢迎fork加星,谢谢!
我的pom文件如下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.yq</groupId><artifactId>MavenPluginDemo</artifactId><version>1.0-SNAPSHOT</version><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.0.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!-- fastjson--><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.1.33</version></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.5</version></dependency><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.7.0</version></dependency><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.7.0</version></dependency><dependency><groupId>io.springfox</groupId><artifactId>springfox-spring-web</artifactId><version>2.7.0</version></dependency></dependencies><repositories><repository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url><snapshots><enabled>false</enabled></snapshots></repository></repositories><build><plugins><!--<plugin>--><!--<groupId>org.apache.maven.plugins</groupId>--><!--<artifactId>maven-jar-plugin</artifactId>--><!--<version>2.4</version>--><!--<configuration>--><!--<archive>--><!--<manifest>--><!--<addClasspath>true</addClasspath>--><!--<classpathPrefix>lib/</classpathPrefix>--><!--<mainClass>com.yq.WebUserApplication</mainClass>--><!--</manifest>--><!--</archive>--><!--</configuration>--><!--</plugin>--><plugin><artifactId>maven-assembly-plugin</artifactId><version>3.1.0</version><configuration><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><!--<plugin>--><!--<groupId>org.springframework.boot</groupId>--><!--<artifactId>spring-boot-maven-plugin</artifactId>--><!--</plugin>--></plugins></build></project>

执行mvn package

D:\E\workspaceGitub\springboot\MavenPluginDemo>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.yq:MavenPluginDemo >-----------------------
[INFO] Building MavenPluginDemo 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ MavenPluginDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ MavenPluginDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to D:\E\workspaceGitub\springboot\MavenPluginDemo\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ MavenPluginDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\E\workspaceGitub\springboot\MavenPluginDemo\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ MavenPluginDemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ MavenPluginDemo ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ MavenPluginDemo ---
[INFO] Building jar: D:\E\workspaceGitub\springboot\MavenPluginDemo\target\MavenPluginDemo-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-assembly-plugin:3.1.0:single (make-assembly) @ MavenPluginDemo ---
[INFO] Building jar: D:\E\workspaceGitub\springboot\MavenPluginDemo\target\MavenPluginDemo-1.0-SNAPSHOT-jar-with-dependencies.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.613 s
[INFO] Finished at: 2018-08-19T19:45:56+08:00
[INFO] ------------------------------------------------------------------------D:\E\workspaceGitub\springboot\MavenPluginDemo>

这里写图片描述
此时执行>java -jar MavenPluginDemo-1.0-SNAPSHOT-jar-with-dependencies.jar
会报错误:MavenPluginDemo-1.0-SNAPSHOT-jar-with-dependencies.jar中没有主清单属性

修改pom文件中maven-assembly-plugin的设置

            <plugin><artifactId>maven-assembly-plugin</artifactId><version>3.1.0</version><configuration><archive><manifest><addClasspath>true</addClasspath><classpathPrefix>lib/</classpathPrefix><mainClass>com.yq.WebUserApplication</mainClass></manifest></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>

注意: **

非常重要。

**
本文示例代码是个spring boot工程,因此一般使用spring-boot-maven-plugin最适合。

            <plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin>

关于spring-boot-maven-plugin请参考https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html

本文使用了maven-assembly-plugin,生成的jar启动时报如下错误。导致项目无法正常运行(这是因为我们的项目是springboot的项目,如果是普通的以main函数所在类启动的,不涉及springboot特有东西的不会出现如下错误)
Caused by: java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
at org.springframework.util.Assert.notEmpty(Assert.java:450) ~[MavenPluginDemo-1.0-SNAPSHOT-jar-with-dependencies.jar:na]

http://www.lbrq.cn/news/1466461.html

相关文章:

  • 外国人 做的中国字网站/企业网站快速建站
  • 大丰市市城乡建设局网站/产品软文范例100字
  • wordpress仪表盘默认/seo课培训
  • 重庆系统建站怎么用/互联网营销师考试内容
  • 如何把自己做的网站 放在网上/什么是核心关键词
  • 一个备案号可以绑定几个网站/济南seo网络优化公司
  • 建设中标查询网站/seo网站关键词优化哪家好
  • 乐清外贸网站建设/如何建造一个网站
  • wordpress 仿站交叉/seo关键字怎么优化
  • wordpress diy插件/seo网站推广下载
  • 郑州做网站哪个/专业网站优化外包
  • 跨境电商平台下载/优化大师是什么
  • 做h网站/查询域名注册信息
  • 合肥做网站建设公司/广东seo网站推广代运营
  • 做网站要学哪些/网站seo的方法
  • 哪些网站布局设计做的比较好的/合肥网站制作公司
  • 开微信公众号要交钱吗/北京seo网站开发
  • 江西赣州258网络推广/seo是指搜索引擎营销
  • 经验范围 网站建设/网站seo
  • 深圳网站建设怎么样/自媒体平台app
  • 德州企业网站优化公司/免费十大软件大全下载安装
  • 策划行业网站/怎样建网站
  • 可以做视频网站的源码/硬件优化大师下载
  • wdcp怎么上传做好的网站/广州网站建设费用
  • 重庆璧山网站建设/广告网络
  • 手绘风格的网站/广州网站优化排名
  • 做网站准备什么/站长工具seo综合查询分析
  • wordpress公司网站插件/2024年4月新冠疫情结束了吗
  • 做资源网站需要什么/竞价排名什么意思
  • 空气能空调如何做网站/亚马逊关键词优化软件
  • 在纯servlet项目中,使用@WebFilter定义了多个filter,如何设置filter的优先级
  • 向华为学习——IPD流程体系之IPD术语
  • DeepCompare文件深度对比软件:专业级文件对比操作全解析
  • Rust × WebAssembly 项目脚手架详解
  • 2018 年 NOI 最后一题题解
  • 第七章:进入Redis的SET核心