栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

java开发中常见的一些命令:maven相关操作

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

java开发中常见的一些命令:maven相关操作

上期回顾

java开发中常见的一些命令:
jar相关操作

maven相关 查看项目结构
mvn dependency:tree

例子如下:
可查看树结构:

[INFO] com.secusoft:bayonet:jar:0.0.1-20210826-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.5.4:compile
[INFO] |  +- org.springframework.boot:spring-boot:jar:2.5.4:compile
[INFO] |  |  - org.springframework:spring-context:jar:5.3.9:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.5.4:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.5.4:compile
[INFO] |  |  +- ch.qos.logback:logback-classic:jar:1.2.5:compile
[INFO] |  |  |  - ch.qos.logback:logback-core:jar:1.2.5:compile
[INFO] |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.14.1:compile
[INFO] |  |  |  - org.apache.logging.log4j:log4j-api:jar:2.14.1:compile
[INFO] |  |  - org.slf4j:jul-to-slf4j:jar:1.7.32:compile
[INFO] |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] |  +- org.springframework:spring-core:jar:5.3.9:compile
[INFO] |  |  - org.springframework:spring-jcl:jar:5.3.9:compile
[INFO] |  - org.yaml:snakeyaml:jar:1.28:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.5.4:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.5.4:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.12.4:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.12.4:compile
[INFO] |  |  - com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.12.4:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.5.4:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.52:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.52:compile
[INFO] |  |  - org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.52:compile
[INFO] |  +- org.springframework:spring-web:jar:5.3.9:compile
[INFO] |  |  - org.springframework:spring-beans:jar:5.3.9:compile
[INFO] |  - org.springframework:spring-webmvc:jar:5.3.9:compile
[INFO] |     - org.springframework:spring-expression:jar:5.3.9:compile
[INFO] +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  - commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- org.springframework.boot:spring-boot-starter-aop:jar:2.5.4:compile
[INFO] |  +- org.springframework:spring-aop:jar:5.3.9:compile
[INFO] |  - org.aspectj:aspectjweaver:jar:1.9.7:compile
[INFO] +- com.aliyun.openservices:ons-client:jar:1.8.8.Final:compile
[INFO] |  - org.slf4j:slf4j-api:jar:1.7.32:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.20:compile (optional)
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.5.4:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.5.4:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.5.4:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.5.0:test
[INFO] |  |  - net.minidev:json-smart:jar:2.4.7:test
[INFO] |  |     - net.minidev:accessors-smart:jar:2.4.7:test
[INFO] |  |        - org.ow2.asm:asm:jar:9.1:test
[INFO] |  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:test
[INFO] |  |  - jakarta.activation:jakarta.activation-api:jar:1.2.2:test
[INFO] |  +- org.assertj:assertj-core:jar:3.19.0:test
[INFO] |  +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] |  +- org.junit.jupiter:junit-jupiter:jar:5.7.2:test
[INFO] |  |  +- org.junit.jupiter:junit-jupiter-api:jar:5.7.2:test
[INFO] |  |  |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] |  |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  |  |  - org.junit.platform:junit-platform-commons:jar:1.7.2:test
[INFO] |  |  +- org.junit.jupiter:junit-jupiter-params:jar:5.7.2:test
[INFO] |  |  - org.junit.jupiter:junit-jupiter-engine:jar:5.7.2:test
[INFO] |  |     - org.junit.platform:junit-platform-engine:jar:1.7.2:test
[INFO] |  +- org.mockito:mockito-core:jar:3.9.0:test
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.10.22:test
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.10.22:test
[INFO] |  |  - org.objenesis:objenesis:jar:3.2:test
[INFO] |  +- org.mockito:mockito-junit-jupiter:jar:3.9.0:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] |  |  - com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  +- org.springframework:spring-test:jar:5.3.9:test
[INFO] |  - org.xmlunit:xmlunit-core:jar:2.8.2:test
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.14:compile
[INFO] |  - commons-codec:commons-codec:jar:1.15:compile
[INFO] +- com.aliyun.oss:aliyun-sdk-oss:jar:3.8.0:compile
[INFO] |  +- org.jdom:jdom:jar:1.1:compile
[INFO] |  +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] |  |  - stax:stax-api:jar:1.0.1:compile
[INFO] |  +- com.aliyun:aliyun-java-sdk-core:jar:3.4.0:compile
[INFO] |  +- com.aliyun:aliyun-java-sdk-ram:jar:3.0.0:compile
[INFO] |  +- com.aliyun:aliyun-java-sdk-sts:jar:3.0.0:compile
[INFO] |  - com.aliyun:aliyun-java-sdk-ecs:jar:4.2.0:compile
[INFO] +- io.minio:minio:jar:8.3.0:compile
[INFO] |  +- com.carrotsearch.thirdparty:simple-xml-safe:jar:2.7.1:compile
[INFO] |  +- com.google.guava:guava:jar:30.0-jre:compile
[INFO] |  |  +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] |  |  +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] |  |  +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] |  |  +- org.checkerframework:checker-qual:jar:3.5.0:compile
[INFO] |  |  +- com.google.errorprone:error_prone_annotations:jar:2.3.4:compile
[INFO] |  |  - com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.4:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.12.4:compile
[INFO] |  - com.fasterxml.jackson.core:jackson-databind:jar:2.12.4:compile
[INFO] - com.squareup.okhttp3:okhttp:jar:4.8.1:compile
[INFO]    +- com.squareup.okio:okio:jar:2.7.0:compile
[INFO]    |  - org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.5.21:compile
[INFO]    - org.jetbrains.kotlin:kotlin-stdlib:jar:1.5.21:compile
[INFO]       - org.jetbrains:annotations:jar:13.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  25.317 s
[INFO] Finished at: 2021-10-01T08:24:16+08:00
[INFO] ------------------------------------------------------------------------



移除某个库中的某个依赖版本
 
            
                xx.xx.xx
                xx
            
            

例子:
在minio中移除okhttp依赖


            io.minio
            minio
            8.3.0
            
            
                com.squareup.okhttp3
                okhttp
            
            
        
maven下载过慢优化

使用阿里云的中央仓库:
在E:mavenapache-maven-3.6.1conf (你maven所在conf文件夹)标签后增加以下代码

	   
      alimaven  
      aliyun maven  
      http://maven.aliyun.com/nexus/content/groups/public/  
      central          
   
maven 编译默认jdk 1.8

在E:mavenapache-maven-3.6.1conf (你maven所在conf文件夹)标签后增加以下代码

	
     jdk-1.8
     
         true
         1.8
     
     
         UTF-8
         1.8
         1.8 
      
	
maven 更改下载保存的地方

maven仓库默认保存位为:

我们进行对应的更改。

 E:repository

去掉注释,最终配置如下:





 
  E:repository
  

 
  
   
  

 
  
   
  

  
  
  

 
  
   
	 
	   
      alimaven  
      aliyun maven  
      http://maven.aliyun.com/nexus/content/groups/public/  
      central          
   
  

  
   
	
     jdk-1.8
     
         true
         1.8
     
     
         UTF-8
         1.8
         1.8 
      
	

  



如何跳过测试打包

有的时候我们打包的话,可能会比较慢。

不跳过测试打包。

命令:mvn package
用了16s

跳过测试打包。

只用了3s

方法一 使用mvn package -Dmaven.test.skip=true 命令 方法二 在idea中将test关闭也可以。

方法三 在pom文件中标签中增加
true

如图:

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/292568.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号