源码编译spring
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
到github 下載一份源代碼
https://github.com/spring-projects/spring-framework
?
我這里放在 D:\gitclone\spring-framework 目錄
構(gòu)建項(xiàng)目前需要下載gradle,到http://gradle.org/下載,然后配置GRADLE_HOME和path路徑
進(jìn)入spring目錄, 執(zhí)行命令: gradle eclipse -x :eclipse
第一次執(zhí)行會(huì)花比較長(zhǎng)的時(shí)間,gradle會(huì)去下載許多依賴(lài)庫(kù),?
也可以在子項(xiàng)目里單獨(dú)構(gòu)建的命令:
D:\gitclone\spring-framework>gradle eclipse -x :eclipse
這個(gè)過(guò)程會(huì)比較漫長(zhǎng),有效子項(xiàng)目也可能因?yàn)榫W(wǎng)絡(luò)問(wèn)題而中斷
可以進(jìn)入到子項(xiàng)目路徑下 執(zhí)行 gradle cleanidea eclipse,來(lái)單獨(dú)構(gòu)建項(xiàng)目
比如D:\gitclone\spring-framework\spring-websocket>gradle cleanidea eclipse
?
構(gòu)建過(guò)程碰到的問(wèn)題
1、spring-core項(xiàng)目里丟失了兩個(gè)jar 包
spring-objenesis-repack-2.4.jar 和spring-cglib-repack-3.2.3.jar
在bulid.gradle 文件里在找到了兩個(gè) 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 項(xiàng)目也丟失了jaxb和xmlbeans jar 包,
我在 spring-oxm 子項(xiàng)目里執(zhí)行
D:\gitclone\spring-framework\spring-oxm>gradle?compileTestJava?
構(gòu)建后就可以
4、子項(xiàng)目spring-beans-groovy提示GroovyDynamicElementReader這個(gè)類(lèi)不存在
原因是需要安裝一個(gè)eclipse的groovy插件。
在eclipse的?Help?->?Install?New?Software?中,添加groovy的下載連接:
http://dist.springsource.org/release/GRECLIPSE/e4.3/
然后全選后,開(kāi)始下載,下載完后,重啟eclipse,然后clean一下項(xiàng)目就搞定了。
解決了所有錯(cuò)誤后,得到我們想要的源碼項(xiàng)目,如下圖,代碼整整齊齊,沒(méi)有報(bào)錯(cuò)很清爽
在官方網(wǎng)站里獲取到 入門(mén)實(shí)例
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的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: PostgreSQL数据库服务端监听设置
- 下一篇: 【R】神经网络相关的R包