In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use IDEA to remotely connect Debug in springboot". In daily operation, I believe many people have doubts about how to use IDEA to remotely connect Debug in springboot. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubt of "how to use IDEA to remotely connect Debug in springboot". Next, please follow the editor to study!
1. First create a Demo ready for remote debugging Note the configuration of the build project 4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.4.RELEASE com.remote.test remote_test 0.0.1-SNAPSHOT remote_test Demo project for Spring Boot 1.8 org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-test test Org.springframework.boot spring-boot-starter-web org.junit.jupiter junit-jupiter-api RELEASE Test org.apache.maven.plugins maven-shade-plugin 2.2 Org.springframework.boot spring-boot-maven-plugin 2.1.4.RELEASE True false *: * META-INF/*.SF META-INF/*.DSA META-INF/*.RSA Package Shade ${project.artifactId}-${project.version}-all META-INF/spring.handlers META-INF/spring.factories META-INF/spring.schemas Com.remote.test.remote_test.RemoteTestApplication Package com.remote.test.remote_test Import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController; import java.util.HashMap;import java.util.Map; @ RestController@RequestMapping ("remote/test") public class UserController {private static final Logger logger = LoggerFactory.getLogger (UserController.class) PostMapping ("selectByUserId") public String selectUserInfo (@ RequestParam ("userId") String userId) {try {Map userInfo = new HashMap (); userInfo.put ("userId", userId); userInfo.put ("age", 23); userInfo.put ("name", "yanshao"); userInfo.put ("address", "shanghai") Logger.info ("Query user information by user ID. UserInfo: {}", userInfo.toString ()); return this.success (userInfo);} catch (Exception e) {logger.error ("Query user information by user ID. UserId: {}", userId, e); return this.fail ();}} private String success (Object data) {Map res = new HashMap () Res.put ("code", 0); res.put ("desc", "success"); res.put ("data", data); return res.toString ();} private String fail () {Map res = new HashMap (); res.put ("code", 1); res.put ("desc", "fail"); return res.toString () 2. Packing
Type: mvn clean package, (probably wait a few minutes), it's best to specify the local repository before building, so you don't need to download the jar package again.
3. Configure remote Debug in IDEA
Specify socket port = 8081, and specify the module to prepare the debug
4. Start the jar package you just typed at the terminal
a. Start debug in IDEA first
b. Then enter the command at the terminal: java-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:8081-jar remote_test-0.0.1-SNAPSHOT-all.jar
5. Test
Mark breakpoints on the interface that is ready for the request
Note: you must start Debug in IDEA before starting the project
➜Desktop java-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:8081-jar remote_test-0.0.1-SNAPSHOT-all.jar
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT
JDWP exit error AGENT_ERROR_TRANSPORT_INIT: No transports initialized [debugInit.c:750]
At this point, the study on "how to use IDEA to remotely connect to Debug in springboot" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.