idea (2020.3版本)编写H3c华三云接口时候,用 maven 管理项目jar,用 gitlab 管理项目。
当项目构建差不多时候,并test没用问题后,准备使用 maven clean,maven package时候出现问题,问题下 一节有截图。
版本:jdk1.8.1 其他版本和项目插件 plugin 版本均有截图:
项目project中使用 maven管理,并在package时候出现问题时候,可以参考这文章,其他酌情参考。
2. 问题出现2-1.问题出现前说明:(仔细看每个图的文字,按照顺序看)
2-2问题附图:【主要解决的问题是这个截图】
3.解决3-1.试着解决:
首先,2中提到解决的方式之一是在springboot下解除其中一个run类,具体报错具体解决,然而处理后,重新 maven package时候还是报同样错;
其次,在pom.xml添加maven-plugin下的 execution中的repackage参数,,依然没解决 如下配置:
org.springframework.boot spring-boot-maven-pluginrepackage
最后:可以解决的是: 在compiler-plugin中添加excludes下的排除一些包和类:
org.apache.maven.plugins maven-compiler-plugin3.8.1 true **/hwapiTestMain.java
3-2:附加提升package要求
附上一些打包需求:在target时候,不想要所有的包编译进去,即:调试类的程序等不想一块打包到 jar库 包里面去,这个就需要在使用 maven 打包的时候把不属于发布内容的部分排除掉。
如何在生产环境里面排除开发环境的 目录、类文件 的方法??
先认识:不同编译器SPring bootorg.springframework.boot spring-boot-maven-plugin
Maven编译器:org.apache.maven.plugins maven-compiler-plugin
无论是SpringBoot or Maven编译器,设置排除项目的方式差不多。
在configuration > excludes 下面添加排除匹配条件。
后处理:** 表示多级目录匹配。
* 表示一级目录匹配。
处理方式上面有截图和说明,这里不拖堂。附上我的整个pom.xml,也不算过分,参考用:
4.总结:4.0.0 org.springframework.boot spring-boot-starter-parent2.6.6 com.huawei hwapi0.0.1-SNAPSHOT hwapi Demo project for Spring Boot 1.8 UTF-8 1.7 1.7 com.huaweicloud.sdk huaweicloud-sdk-all3.0.84 org.projectlombok lombok1.18.12 org.slf4j slf4j-api1.7.25 org.apache.httpcomponents httpclient4.5.5 com.alibaba fastjson1.2.47 io.springfox springfox-swagger22.9.2 io.swagger swagger-modelsguava com.google.guava com.sun.xml.bind jaxb-impl2.3.0 org.jetbrains annotations13.0 commons-lang commons-lang2.6 com.google.code.gson gson2.8.5 org.springframework.boot spring-boot-starter-data-jpaorg.springframework.boot spring-boot-starter-thymeleaforg.springframework.boot spring-boot-starter-weborg.springframework.boot spring-boot-configuration-processormysql mysql-connector-javaruntime org.springframework.boot spring-boot-starter-testtest org.projectlombok lombokRELEASE compile org.projectlombok lombokorg.apache.maven.plugins maven-compiler-plugin3.8.1 true **/hwapiTestMain.java org.apache.maven.plugins maven-surefire-plugin2.22.2 true org.springframework.boot spring-boot-maven-pluginrepackage
1.maven打包过程一定看console,盯着问题。
2. 先clean 在package 。
3.问题不大,高手碰见该问题直接掠过该文章。完毕。



