源码编译spring
2019獨角獸企業(yè)重金招聘Python工程師標準>>>
到github 下載一份源代碼
https://github.com/spring-projects/spring-framework
?
我這里放在 D:\gitclone\spring-framework 目錄
構(gòu)建項目前需要下載gradle,到http://gradle.org/下載,然后配置GRADLE_HOME和path路徑
進入spring目錄, 執(zhí)行命令: gradle eclipse -x :eclipse
第一次執(zhí)行會花比較長的時間,gradle會去下載許多依賴庫,?
也可以在子項目里單獨構(gòu)建的命令:
D:\gitclone\spring-framework>gradle eclipse -x :eclipse
這個過程會比較漫長,有效子項目也可能因為網(wǎng)絡(luò)問題而中斷
可以進入到子項目路徑下 執(zhí)行 gradle cleanidea eclipse,來單獨構(gòu)建項目
比如D:\gitclone\spring-framework\spring-websocket>gradle cleanidea eclipse
?
構(gòu)建過程碰到的問題
1、spring-core項目里丟失了兩個jar 包
spring-objenesis-repack-2.4.jar 和spring-cglib-repack-3.2.3.jar
在bulid.gradle 文件里在找到了兩個 task ?cglibRepackJar和objenesisRepackJar
http://www.blogjava.net/wldandan/archive/2012/06/27/381605.html
| C:\Users\Administrator>D: |
構(gòu)建后就行了
2、我發(fā)現(xiàn)spring-oxm 項目也丟失了jaxb和xmlbeans jar 包,
我在 spring-oxm 子項目里執(zhí)行
D:\gitclone\spring-framework\spring-oxm>gradle?compileTestJava?
構(gòu)建后就可以
4、子項目spring-beans-groovy提示GroovyDynamicElementReader這個類不存在
原因是需要安裝一個eclipse的groovy插件。
在eclipse的?Help?->?Install?New?Software?中,添加groovy的下載連接:
http://dist.springsource.org/release/GRECLIPSE/e4.3/
然后全選后,開始下載,下載完后,重啟eclipse,然后clean一下項目就搞定了。
解決了所有錯誤后,得到我們想要的源碼項目,如下圖,代碼整整齊齊,沒有報錯很清爽
在官方網(wǎng)站里獲取到 入門實例
http://projects.spring.io/spring-framework/
| package hello;public interface MessageService {String getMessage(); } |
| package hello;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component;@Component public class MessagePrinter {final private MessageService service;@Autowiredpublic MessagePrinter(MessageService service) {this.service = service;}public void printMessage() {System.out.println(this.service.getMessage());} } |
| package hello;import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.*;@Configuration @ComponentScan public class Application {@BeanMessageService mockMessageService() {return new MessageService() {public String getMessage() {return "Hello World!";}};}public static void main(String[] args) {ApplicationContext context = new AnnotationConfigApplicationContext(Application.class);MessagePrinter printer = context.getBean(MessagePrinter.class);printer.printMessage();} } |
?
?
?
?
?
?
?
轉(zhuǎn)載于:https://my.oschina.net/zhongwenhao/blog/701071
總結(jié)
以上是生活随笔為你收集整理的源码编译spring的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PostgreSQL数据库服务端监听设置
- 下一篇: 【R】神经网络相关的R包