# Java笔记 **Repository Path**: yqw123/JavaBiJi ## Basic Information - **Project Name**: Java笔记 - **Description**: 开发过程中java的一些使用技巧总结 - **Primary Language**: Java - **License**: EPL-1.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-11-04 - **Last Updated**: 2021-04-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Java笔记 ## 个人简介 ## 泛型新玩法 - 泛型技巧`ConcurrentMap newConcurrentMap = Maps.newConcurrentMap();` ``` @Test public void mapTest() { LinkedHashMap newConcurrentMap = Maps.newLinkedHashMapWithExpectedSize(1); System.out.println("mapTest: " + newConcurrentMap); } //打印结果:mapTest: {} @Test public void createMapTest() { LinkedHashMap newConcurrentMap = Maps.newLinkedHashMapWithExpectedSize(1); System.out.println("createMapTest: " + newConcurrentMap); } //打印结果:createMapTest: {} ``` ## 接口实现类之枚举实现巧用 ``` enum NullListener implements RemovalListener { INSTANCE; @Override public void onRemoval(RemovalNotification notification) {} } enum OneWeigher implements Weigher { INSTANCE; @Override public int weigh(Object key, Object value) { return 1; } } ``` ## Map- put技巧 ``` Map putIfAbsent = new HashMap<>(); System.out.println(putIfAbsent.put(1, "张三")); System.out.println(putIfAbsent.putIfAbsent(2, "李四")); System.out.println("put==" + putIfAbsent.put(2, "丁力")); System.out.println("put==" + putIfAbsent.put(2, "丁力")); System.out.println("putIfAbsent==" + putIfAbsent.putIfAbsent(1, "王五")); System.out.println("putIfAbsent==" + putIfAbsent.putIfAbsent(1, "王五")); putIfAbsent.forEach((key,value)->{ System.out.println("key = " + key + ", value = " + value); }); ``` ## Maven命令行窗口指定settings.xml maven命令行窗口指定特定settings.xml ,在命令行界面指定settings.xml,需加入如下参数: ``` //指定使用配置xml编译项目 mvn install --settings d:\maven\conf\settings.xml  mvn install -s d:\maven\conf\settings.xml  //指定使用配置xml编译项目 并忽略单元测试代码 mvn clean package --settings d:\maven\conf\\settings.xml -Dmaven.test.skip=true mvn clean package -s d:\maven\conf\\settings.xml -Dmaven.test.skip=true - Maven查看当前生效的settings.xml 用mvn help:effective-settings可以查看当前生效的settings.xml: mvn -X命令可以查看settings.xml文件的读取顺序: 总结: maven-help-plugin是一个小巧的辅助工具, 最简单的mvn help:system可以打印所有可用的环境变量和Java系统属性。 mvn help:effective-pom和mvn help:effective-settings最为有用。 mvn help:effective-pom用于查看当前生效的POM内容,指合并了所有父POM(包括Super POM)后的XML,所以可用于检测POM中某个配置是否生效 mvn effective-settings可用于查看当前生效的settings.xml文件内容,所以可用于判断某个settings配置是否生效 ``` [maven全局配置文件settings.xml详解](https://www.cnblogs.com/jingmoxukong/p/6050172.html?utm_source=gold_browser_extension)