打包会有问题
root lib-A
当前是需要直接打root的jar包,但是lib包下面有直接引用的本地jar并不在maven仓库当中使用如下
格式如下:
| 1 | <dependency> | 
打包中如果有测试代码编译不通过的可用参考添加
| 1 | <plugin> | 
我后面发现打的jar包lib文件夹下面的确是有lib-A项目,但是啊就是跑的后面一旦涉及引用lib-A下面的本地第三方jar就说类找不到网上有人给出如下解决方案
| 1 | <plugin> | 
我分别在lib-A和root项目下添加了,神奇的事发生了,打包的后服务可以运行,但是lib-A下面的controller全都没有,对应的请求都是404,人都快裂开了
只能排除法先注释root下发现不行,后面注释lib-A下居然成功了,真TMD邪门
补充maven install 包含外部jar的打包情况——-
参考链接
- java - Maven add jars through systemPath/system but not added to war or anywhere else - Stack Overflow
- Maven package 时出现should not point at files within the project directory_隐0士的博客-CSDN博客
在maven的pom文件中引用本地的jar
| 1 | <dependency> | 
但是打包时会报错
should not point at files within the project directory dependencies.dependency.systemPath
在stackoverflow上有两种方式
第一种是pom中添加jar所在文件夹的仓库
| 1 | <repositories> | 
但是在打包的时候还是会出问题
第二种使用plugin来实现
| 1 | <build> | 
tips 下面的两种尝试过失败也列出来
- 使用configuration复制来自于网络和正确的配置有出入 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16- <execution> 
 <id>pinyin4j</id>
 <phase>compile</phase>
 <configuration>
 <file>${pom.basedir}/src/main/resources/lib/pinyin4j-2.5.0.jar</file>
 <repositoryLayout>default</repositoryLayout>
 <groupId>com.belerweb</groupId>
 <artifactId>pinyin4j</artifactId>
 <version>2.5.0</version>
 <packaging>jar</packaging>
 <generatePom>true</generatePom>
 </configuration>
 <goals>
 <goal>pinyin4j</goal>
 </goals>
 </execution>
- 使用 - clean - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16- <execution> 
 <id>pinyinAnalyzer</id>
 <phase>clean</phase>
 <configuration>
 <file>${pom.basedir}/src/main/resources/lib/pinyinAnalyzer4.3.1.jar</file>
 <repositoryLayout>default</repositoryLayout>
 <groupId>com.shentong</groupId>
 <artifactId>pinyinAnalyzer</artifactId>
 <version>4.3.1</version>
 <packaging>jar</packaging>
 <generatePom>true</generatePom>
 </configuration>
 <goals>
 <goal>install-file</goal>
 </goals>
 </execution>
- 使用phase>init</phase - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16- <execution> 
 <id>pinyinAnalyzer</id>
 <phase>init</phase>
 <configuration>
 <file>${pom.basedir}/src/main/resources/lib/pinyinAnalyzer4.3.1.jar</file>
 <repositoryLayout>default</repositoryLayout>
 <groupId>com.shentong</groupId>
 <artifactId>pinyinAnalyzer</artifactId>
 <version>4.3.1</version>
 <packaging>jar</packaging>
 <generatePom>true</generatePom>
 hconfiguration>
 <goals>
 <goal>install-file</goal>
 </goals>
 </execution>
之前一直用IntelliJ IDEA 的直接下载jar包,但是这次一直下载不下来指定版本jar包,看本地的代码库localRepository本地没有,看本地部署的maven中心,所以使用了参考地址
- 创建pom.xml 文件
| 1 | 
 | 
- 使用mvn命令 下载后在本地仓库看到, 然后在IntelliJ IDEA刷新
| 1 | mvn dependency:copy-dependencies | 
 
                                