源码搭建
公司项目组今年的项目主要将采用SpringBoot 进行开发,在开发过程中顺便学习下SpringBoot源码。
环境 | 版本 | 备注 |
---|---|---|
Maven | 3.6.1 | 3.5+ |
JDK | 1.8.0_101 | 1.8+ |
SpringBoot | 2.1.4.RELEASE |
源码包下载
下载地址: https://github.com/spring-projects/spring-boot/tree/v2.1.4.RELEASE
解压编译
unzip spring-boot-2.1.4.RELEASE.zip
cd spring-boot-2.1.4.RELEASE
sudo mvn install -DskipTests -Pfast
项目导入
问题:pom.xml 文件报错 GC overhead limit exceeded
解决方法:
问题 源码包中示例运行失败
Error:Maven Resources Compiler: Failed to copy '/Users/xxxxxx/Desktop/spring-boot-2.1.4.RELEASE/spring-boot-project/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif' to '/Users/xxxxxxxx/Desktop/spring-boot-2.1.4.RELEASE/spring-boot-project/spring-boot-test-autoconfigure/target/test-classes/org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif': /Users/xxxxxxxx/Desktop/spring-boot-2.1.4.RELEASE/spring-boot-project/spring-boot-test-autoconfigure/target/test-classes/org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif (Permission denied)
原因是权限问题,编译完成之后有写文件的权限是root
解决办法:
以Mac OS为例,将源码包下的所有文件用户和用户组修改为可访问的
sudo chown -R ${your usernmae}:staff spring-boot-2.1.4.RELEASE
建立测试项目
可直接运行项目中samples然后打断点跟代码,也可以自己建测试项目。
在源码的示例目录下新建子模块
修改pom.xml文件
可以开始打断点跟代码了。