1、问题:mvn 编译或执行时告警某些输入文件使用了未经检查或不安全的操作
通过mvn命令来编译代码时,如mvn clean compile,有时会出现WARNING编译警告,只是提示某个类,但是没有提示具体哪行代码,提示加上-Xlint:unchecked来查看详细信息。
按提示加上:mvn clean compile -Xlint:unchecked 进行编译,提示:没有lint控件
2、解决办法
2.1、在pom.xml中加上<compilerArgument>
<plugin> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.8</source> <target>1.8</target> <compilerArgument>-Xlint:unchecked</compilerArgument> </configuration> </plugin>
再次编译mvn clean compile,可以查看到哪个类的哪行有问题。
2.2、修改如下:
HashMap<> AlgorithmsJson=getAlgorithmsJson(AlgorithmTypeList); public HashMap<String,String> getAlgorithmsJson(List<String> AlgorithmTypeList){} 修改成: HashMap<String,String> AlgorithmsJson=getAlgorithmsJson(AlgorithmTypeList); public HashMap<String,String> getAlgorithmsJson(List<String> AlgorithmTypeList){}
其他的修改:
Map<String, Object> map = new LinkedHashMap();
改成:
Map<String, Object> map = new LinkedHashMap<>();
问题:对作为原始类型com.mongodb.client.MongoCollection的成员的insertOne(TDocument)的调用未经过检查
MongoCollection dbColl= mongoClient.getDatabase(dbName).getCollection(coll);
public List<AoeData> query(MongoCollection collection){}
修改:
MongoCollection<Document> dbColl= mongoClient.getDatabase(dbName).getCollection(coll);
public List<AoeData> query(MongoCollection<Document> collection){}