版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lkx444368875/article/details/80367587
maven
idea maven打包的时候,针对SNAPSHOT结尾的jar包从maven服下载到本地的时候是类似于cachecloud-open-client-basic-1.0-20180507.072005-3.jar样子 , 导致运行的时候没有找到jar包
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<!--<packagingExcludes>WEB-INF/web.xml</packagingExcludes>-->
<!--<warName>${profiles.active}</warName>-->
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>elab-common-service</warName>
<!-- 打出的jar包去掉时间戳,按照原始的格式输出 -->
<outputFileNameMapping>@{artifactId}@-@{baseVersion}@.@{extension}@</outputFileNameMapping>
</configuration>
</plugin>
JDK 1.8 Maven 打包的时候会出现文档编译出错,正确的设定方式
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<!--<version>2.9</version>-->
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<!-- 这一段很关键 -->
<additionalOptions>
<additionalOption>-Xdoclint:none</additionalOption>
</additionalOptions>
</configuration>
</execution>
</executions>
</plugin>
mongodb
如果实体中的字段和mongo库中的字段不对应
@Field("property_type")
private String propertyType;
读取jar包中的配置文件读取成File对象
/**
* 将file文件copy到指定位置之后,然后再返回
*
* @param path
* @return
*/
public List<File> getJarFileList(String path) {
List<File> list = new ArrayList<>();
//获取容器资源解析器
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
File ttfFile = null;
try {
//获取所有匹配的文件
Resource[] resources = resolver.getResources(path + "*.*");
for (Resource resource : resources) {
//获得文件流,因为在jar文件中,不能直接通过文件资源路径拿到文件,但是可以在jar包中拿到文件流
InputStream stream = resource.getInputStream();
log.debug(" 读取的文件流 [" + stream + "]");
String targetFilePath = "/tmp/" + path + resource.getFilename();
log.debug(" 放置位置 [" + targetFilePath + "]");
ttfFile = new File(targetFilePath);
FileUtils.copyInputStreamToFile(stream, ttfFile);
list.add(ttfFile);
}
} catch (IOException e) {
log.warn("读取文件流失败,写入本地库失败! " + e);
}
return list;
}