[springboot project] Start error reporting collection in idea

1. Solution to the error "Error running 'Application': Command line is too long." reported in IDEA

Error report details:

Error running 'Application':
Command line is too long.Shorten command line for Application or also for Spring Boot default configuration.

Reason for error: SpringBoot startup command is too long

Solution:
Method 1: Click on the project startup configuration item -> shorten command line option and select classpath file or java manifest option -> restart the project to run
Insert image description here

Reference link: https://blog.csdn.net/qq_42730111/article/details/115698121

Method 2:
In the component in .idea/libraies/workspace.xml <component name="PropertiesComponent">, add code:

<property name="dynamic.classpath" value="true" />

Insert image description here

Reference link: https://blog.csdn.net/weixin_43405300/article/details/123806649

二、Non-resolvable import POM: Cannot access -public (http://.1*.4.*9/nexus/content/reposit

Error report details:

[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

Solution: Operation menu path File—Settings—Build, Execution, Deployment—Build Tools—Maven—Cancel Work offline

Insert image description here

Reference link: https://blog.csdn.net/sun_luming/article/details/119948077

3. Unable to start embedded Tomcat (solved)Insert image description here

Solution: It may be because the jdk version is not selected, just select it.

Insert image description here

Reference link: https://blog.csdn.net/javaXiaoAnRan/article/details/98214525

4. com.mongodb.MongoSocketOpenException: Exception opening socket error solution

Error message:

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

Reason: Springboot is automatically configured to support mongodb. When springboot is started, a mongo instance will be automatically instantiated. If you need to disable automatic configuration, add the @SpringBootApplication(exclude = MongoAutoConfiguration.class) annotation.

Or comment the Mongo-related startup statements in the pom.xml file, as follows:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>

Reference link: https://blog.csdn.net/weixin_45157411/article/details/123581713

5. When the project is started, an error is reported: nested exception is java.lang.RuntimeException: Failed to initialize DiscoveryClient!

Reason:
When introducing the two dependencies of spring-cloud-starter-netflix-eureka-client and spring-boot-starter-web, conflicts will occur. Because in the code, the Rest method of Spring MVC is used, but the spring-cloud-starter-netflix-eureka-client itself contains the Jesery Rest method. causing an error

Solution:
Method 1: Drain Jersey in spring-cloud-starter-netflix-eureka-server

<dependency> 
     <groupId>org.springframework.cloud</groupId> 
     <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> 
</dependency> 

Change to:

<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> 

Method 2: Do not reference spring-boot-starter-web and delete 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> 
-->

Reference link: https://blog.csdn.net/weixin_42861564/article/details/101303708

Guess you like

Origin blog.csdn.net/m0_46459413/article/details/132190884