1.unable to open debugger port(127.0.0.1:2682):java.net.SocketException "Interrupted function call:accept failed
正常是windows的话打开cmd,输入
netstat -aon|findstr "2682"
找到占用这个端口的进程,然后使用下面这个命令kill掉
taskkill -f -pid 15680
但是我查了,没有进程,我就用run启动,结果报错我的tomcat端口8081占用了,改了以后就能启动了
2.如何发现jar包冲突以及如何解决
参考这个(写的很好):如何排查jar包冲突
插件maven helper的下载方法:
File-->setting--->Plugins--->在搜索框中填写Maven Helper然后搜索,单击Install按钮进行安装,装完重启IDE。
如出现下面错误,
Your settings indicates, that conflicts will not be visible, see IDEA-133331
可以这么解决
根据图中的错误提示,我们可以找到 IDEA-133331 这个issue的问题,根据里面的描述,为了修正这个问题,我们可以这样干:
在IntelliJ的 Settings → Build, Execution, Deployment → Build Tools → Maven → Importing
中,为“VM options for importer”添加上“
-Didea.maven3.use.compat.resolver
”参数,例如,原来我的这个参数为“-Xmx512m ”,修改之后变成了:
-Xmx512m -Didea.maven3.use.compat.resolver
注意,根据上面提到的issue链接里的描述,这个参数修改对不同的IntelliJ版本是不同的。这样修改之后,就可以看到Dependency Analyzer结果了。
下面记录一下我碰到的jar包冲突:
这个项目下的maven依赖都报红,编译也不通过,但是编译报的错误全部都是包找不到,但是这个jar包确实引入了,而且不是一两个的jar包找不到,好多个。这个时候其实可以通过install报的错误来得到最准确的报错信息
[ERROR] Failed to execute goal on project help-tool: Could not resolve dependencies for project com.luoyu.zyzy:help-tool:jar:0.0.3-importserver-replaced-SNAPSHOT: Failed to collect dependencies for [net.sf.ehcache:ehcache:jar:2.10.1 (compile), com.luoyu.zyzy:import-wdsession:jar:0.0.3-SNAPSHOT (compile), com.luoyu.zyzy:import-query:jar:0.0.3-SNAPSHOT (compile), de.ruedigermoeller:fst:jar:2.45 (compile), com.luoyu.sso.agent:sso-java-agent:jar:1.0.1 (compile), com.luoyu.um.client:um-client:jar:1.9.0 (compile), redis.clients:jedis:jar:2.6.0 (provided?), com.alibaba:druid:jar:1.0.9 (provided?), com.oracle:ojdbc6:jar:11.1.0.6 (provided?), com.alibaba:dubbo:jar:2.5.3 (provided?), org.apache.zookeeper:zookeeper:jar:3.4.6 (provided?), com.github.sgroschupf:zkclient:jar:0.1 (provided?), javassist:javassist:jar:3.12.1.GA (provided?), com.alibaba:fastjson:jar:1.2.58 (provided?), org.springframework:spring-context:jar:3.2.4.RELEASE (provided?), org.springframework:spring-beans:jar:3.2.4.RELEASE (provided?), org.springframework:spring-webmvc:jar:3.2.4.RELEASE (provided?), org.springframework:spring-jdbc:jar:3.2.4.RELEASE (provided?), org.springframework:spring-aspects:jar:3.2.4.RELEASE (provided?), org.springframework:spring-test:jar:3.2.4.RELEASE (provided?), org.mybatis:mybatis:jar:3.2.8 (provided?), org.mybatis:mybatis-spring:jar:1.2.2 (provided?), org.slf4j:slf4j-log4j12:jar:1.6.4 (provided?), com.fasterxml.jackson.core:jackson-databind:jar:2.9.9.1 (provided?), org.apache.httpcomponents:httpclient:jar:4.3.5 (provided?), jstl:jstl:jar:1.2 (provided?), javax.servlet:servlet-api:jar:3.0 (provided?), javax.servlet:jsp-api:jar:2.0 (provided?), joda-time:joda-time:jar:2.5 (provided?), org.apache.commons:commons-email:jar:1.4 (provided?), org.apache.commons:commons-lang3:jar:3.3.2 (provided?), commons-io:commons-io:jar:2.2 (provided?), commons-codec:commons-codec:jar:1.9 (compile), org.hibernate:hibernate-validator:jar:5.1.3.Final (compile), javax.validation:validation-api:jar:1.1.0.Final (compile), com.netflix.hystrix:hystrix-core:jar:1.5.12 (provided?), com.netflix.hystrix:hystrix-metrics-event-stream:jar:1.5.12 (provided?), com.google.protobuf:protobuf-java:jar:3.0.0 (provided?), io.springfox:springfox-swagger-ui:jar:2.5.0 (provided?), org.apache.curator:curator-framework:jar:2.6.0 (provided?), jcifs:jcifs:jar:1.3.17 (provided?), commons-httpclient:commons-httpclient:jar:3.0 (provided?), commons-discovery:commons-discovery:jar:0.5 (provided?), com.microsoft.ewsjavaapi:exchange-ws-api:jar:1.1.5.2 (provided?), com.luoyu:hippo-core:jar:2.0.0q-SNAPSHOT (compile)]: Failed to read artifact descriptor for com.alibaba:fastjson:jar:1.2.58: Could not transfer artifact com.alibaba:fastjson:pom:1.2.58 from/to mirror (http://maven.luoyu.com.cn/repository/maven-public): Failed to transfer file: http://maven.luoyu.com.cn/repository/maven-public/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.pom. Return code is: 423 , ReasonPhrase:Artifact com.alibaba:fastjson:1.2.58 is not allowed to be downloaded for the reason that it has a vulnerability whose key is 20190910154411. Please visit the link for details : http://maven.luoyu.com.cn//#/vulner/6/detail. -> [Help 1
这个内容很长,但是前面都不是关键错误,最后面才是,也就是这部分
Failed to read artifact descriptor for com.alibaba:fastjson:jar:1.2.58: Could not transfer artifact com.alibaba:fastjson:pom:1.2.58 from/to mirror (http://maven.luoyu.com.cn/repository/maven-public): Failed to transfer file: http://maven.luoyu.com.cn/repository/maven-public/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.pom. Return code is: 423 , ReasonPhrase:Artifact com.alibaba:fastjson:1.2.58 is not allowed to be downloaded for the reason that it has a vulnerability whose key is 20190910154411. Please visit the link for details :
【解决办法一】所以可以把错误提示信息copy出来,然后粘贴到notepad++,找到最后报的错误内容,可以看到最后报错说的是fastjson读取不到,最终我是专门引入了fastjson的高版本,然后排除其他jar包中引入fastjson
【解决办法二】既然知道是因为fastjson版本低引起的问题,那就全局统一设置引用一个高版本的fastjson,如果这个pom.xml的依赖A依赖了fastjson那就自动拉新包,忽略依赖A设置的fastjson版本。这个要怎么设置呢,在pom.xml中设置如下
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.72</version>
</dependency>
</dependencies>
</dependencyManagement>
我把它配置在了properties的下面,这样直接不用排除别的包的fastjson依赖就好了,更简单。
相关依赖知识:
共有四种解决方式:
1、第一声明优先原则:
在pom.xml配置文件中,如果有两个名称相同版本不同的依赖声明,那么先写的会生效。
所以,先声明自己要用的版本的jar包即可。
2、路径近者优先:
直接依赖优先于传递依赖,如果传递依赖的jar包版本冲突了,那么可以自己声明一个指定版本的依赖jar,即可解决冲突。
3、排出原则:
传递依赖冲突时,可以在不需要的jar的传递依赖中声明排除,从而解决冲突。
例子:
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.3.24</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
</exclusions>
</dependency>
4、版本锁定原则(最常使用)
在配置文件pom.xml中先声明要使用哪个版本的相应jar包,声明后其他版本的jar包一律不依赖。解决了依赖冲突。
例子:
<properties>
<spring.version>4.2.4.RELEASE</spring.version>
<hibernate.version>5.0.7.Final</hibernate.version>
<struts.version>2.3.24</struts.version>
</properties>
<!-- 锁定版本,struts2-2.3.24、spring4.2.4、hibernate5.0.7 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</dependencyManagement>