一、IDEA中报错 “Error running ‘Application‘: Command line is too long.“ 的解决办法
报错详情:
Error running 'Application':
Command line is too long.Shorten command line for Application or also for Spring Boot default configuration.
报错原因: SpringBoot 启动命令过长
解决方案:
方法一: 点击项目启动配置项 -> shorten command line 选项选择 classpath file 或 java manifest 选项 -> 重新启动工程运行即可
参考链接:https://blog.csdn.net/qq_42730111/article/details/115698121
方法二:
在 .idea/libraies/workspace.xml 中的 <component name="PropertiesComponent">
组件中,添加代码:
<property name="dynamic.classpath" value="true" />
参考链接:https://blog.csdn.net/weixin_43405300/article/details/123806649
二、Non-resolvable import POM: Cannot access -public (http://.1*.4.*9/nexus/content/reposit
报错详情:
[ERROR] Non-resolvable import POM: Cannot access *-public (http://1.1.4.1*9/nexus/content/repositories/public/) in offline mode and the artifact org.springframework.cloud:spring-cloud-dependencies:pom
解决方案: 操作菜单路径 File—Settings—Build,Execution,Deployment—Build Tools—Maven—取消Work offline
参考链接:https://blog.csdn.net/sun_luming/article/details/119948077
三、Unable to start embedded Tomcat(已解决)
解决方案: 可能是没有选择jdk版本的原因,选上就可以了
参考链接:https://blog.csdn.net/javaXiaoAnRan/article/details/98214525
四、com.mongodb.MongoSocketOpenException: Exception opening socket错误解决方法
报错信息:
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) ~[mongodb-driver-core-3.4.2.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_131]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_131]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_131]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_131]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_131]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_131]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_131]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_131]
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:57) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongodb-driver-core-3.4.2.jar:na]
... 3 common frames omitted
原因: springboot自动配置了支持mongodb。在启动springboot时会自动实例化一个mongo实例,需要禁用自动配置 ,增加@SpringBootApplication(exclude = MongoAutoConfiguration.class)这个注解即可
或者在 pom.xml 文件中注释Mongo相关的启动语句,如下:
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
参考链接:https://blog.csdn.net/weixin_45157411/article/details/123581713
五、项目启动时,报错:nested exception is java.lang.RuntimeException: Failed to initialize DiscoveryClient!
原因:
引入spring-cloud-starter-netflix-eureka-client和spring-boot-starter-web两个依赖的时候,会出现冲突。由于代码里面,用了Spring MVC的Rest方式,而没有用spring-cloud-starter-netflix-eureka-client本身包含Jesery Rest方式。而导致报错
解决方式:
方法一: 在spring-cloud-starter-netflix-eureka-server排出Jersey
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
改为:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> <!-- 排除Jersey,用SpringMVC Rest方式--><exclusions><exclusion><groupId>com.sun.jersey</groupId><artifactId>jersey-client</artifactId></exclusion><exclusion><groupId>com.sun.jersey</groupId><artifactId>jersey-core</artifactId></exclusion><exclusion><groupId>com.sun.jersey.contribs</groupId><artifactId>jersey-apache-client4</artifactId></exclusion></exclusions>
</dependency>
方法二: 不引用spring-boot-starter-web,把spring-boot-starter-web删去
<-- 去掉
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId></exclusion></exclusions>
</dependency>
-->
参考链接:https://blog.csdn.net/weixin_42861564/article/details/101303708