SpringBoot2.2.13源码调试

本文介绍了SpringBoot2.2.13的源码调试过程,包括修改源码包的pom.xml配置,重新编译项目,创建用于调试的module,设计Controller接口以及启动项目进行验证。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SpringBoot2.2.13源码调试

一、源码调试环境搭建验证

1、修改源码包中的pom.xml的配置

	<properties>
		<!--建议修改 Springboot的版本号,避免和官方版本号产生冲突-->
		<revision>2.2.13.RELEASE.aibei</revision>
		<main.basedir>${basedir}</main.basedir>
		<!--这个配置:关闭Maven代码检查-->
		<disable.checks>true</disable.checks>
	</properties>

2、重新编译源码项目

  • mvn clean install -DskipTests -Pfast

  • [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  04:26 min
    [INFO] Finished at: 2024-04-05T10:12:37+08:00
    [INFO] ------------------------------------------------------------------------
    [INFO] 1266 goals, 1130 executed, 136 from cache, saving at least 13s
    [INFO] 
    [INFO] A build scan was not published as you have not authenticated with server 'ge.spring.io'.
    
    

3、新建一个module用户源码调试

*新建模块

  • 修改pom文件

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
    		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    	<modelVersion>4.0.0</modelVersion>
    
    	<parent>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-starter-parent</artifactId>
    		<!--将这里的版本号,修改成自己刚刚编译的版本号,方便调试 -->
    		<version>2.2.13.RELEASE.aibei</version>
    		<relativePath/> <!-- lookup parent from repository -->
    	</parent>
    
    	<groupId>com.ai_bei</groupId>
    	<artifactId>springboot-ai-bei-tests</artifactId>
    	<version>1.0-SNAPSHOT</version>
    
    	<properties>
    		<maven.compiler.source>17</maven.compiler.source>
    		<maven.compiler.target>17</maven.compiler.target>
    		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    	</properties>
    
    	<dependencies>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-web</artifactId>
    		</dependency>
    	</dependencies>
    
    </project>
    

4、新建Controller接口验证源码调试接口

package com.aibei.springboot.test.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Copyright (C), 2010-2023
 * FileName:     TestController
 * Author:       shine
 * Date:         2024/4/5 10:29
 * Description:
 * History:
 * <author>      <time>          <version>          <desc>
 * 作者姓名       修改时间         版本号             描述
 */
@RestController
public class TestController {

	@GetMapping("/test")
	public String test(){
		return "Success";
	}
}


5、启动项目验证

package com.aibei.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Copyright (C), 2010-2023
 * FileName:     SpringbootAIBeiTestApplications
 * Author:       shine
 * Date:         2024/4/5 10:32
 * Description:
 * History:
 * <author>      <time>          <version>          <desc>
 * 作者姓名       修改时间         版本号             描述
 */
@SpringBootApplication
public class SpringbootAIBeiTestApplication {
	public static void main(String[] args) {
		SpringApplication.run(SpringbootAIBeiTestApplication.class, args);
	}
}
## 通过 curl 访问接口验证
PS C:\Users\shine> curl http://localhost:8080/test
StatusCode        : 200
StatusDescription :
Content           : Success
RawContent        : HTTP/1.1 200
                    Keep-Alive: timeout=60
                    Connection: keep-alive
                    Content-Length: 7
                    Content-Type: text/plain;charset=UTF-8
                    Date: Fri, 05 Apr 2024 02:39:04 GMT
                    Success
Forms             : {}
Headers           : {[Keep-Alive, timeout=60], [Connection, keep-alive], [Content-Length, 7], [Content-Type, text/plain;charset=UTF-8]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 7
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

深漂的小小小刘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值