天天看點

tomcat8.5 源碼分析(一)導入eclipse

本文主要參考了文章http://blog.csdn.net/zhangjikuan/article/details/52594828,但發現有些不足。現在補充

tomcat8.5源碼分析(一):導入eclipse SVN用戶端下載下傳源代碼 配置ant 關于build 主要還是要參考官方網站 修改 base.path=E:/J2EE/tomcat/libraries-tomcat8.0

在tomcat目錄下執行 ~/Downloads/apache-ant-1.9.7/bin/ant ide-eclipse 報錯log如下: downloadzip: [get] Getting: https://objenesis.googlecode.com/files/objenesis-1.2-bin.zip [get] To: /Users/jikuan.zjk/tomcat-build-libs/download-1580874369.zip [get] Error opening connection java.io.FileNotFoundException: https://objenesis.googlecode.com/files/objenesis-1.2-bin.zip [get] Error opening connection java.io.FileNotFoundException: https://objenesis.googlecode.com/files/objenesis-1.2-bin.zip [get] Error opening connection java.io.FileNotFoundException: https://objenesis.googlecode.com/files/objenesis-1.2-bin.zip [get] Can't get https://objenesis.googlecode.com/files/objenesis-1.2-bin.zip to /Users/jikuan.zjk/tomcat-build-libs/download-1580874369.zip BUILD FAILED /Users/jikuan.zjk/Documents/workspace/apache-tomcat-8.5.4-src/build.xml:2637: The following error occurred while executing this line: /Users/jikuan.zjk/Documents/workspace/apache-tomcat-8.5.4-src/build.xml:2741: Can't get https://objenesis.googlecode.com/files/objenesis-1.2-bin.zip to /Users/jikuan.zjk/tomcat-build-libs/download-1580874369.zip 原因是Google下載下傳不下來objenesis-1.2.jar包 。 類似這種問題,把 objenesis-1.2 放到maven中下載下傳下來,然後複制到 目标檔案夾中去。具體路徑、檔案夾名稱、版本号可以參考ant配置檔案build.properties。

~/Downloads/apache-ant-1.9.7/bin/ant ide-eclipse 這時候就會轉換成功了,轉換成了eclipse工程,會發現tomcat源碼檔案下會出現.classpath 和.project檔案

導入工程 file->import->Existing Project into workspace->選擇工程 這樣會有錯誤,是沒有導入jar包的問題 ,看圖說話

tomcat8.5 源碼分析(一)導入eclipse

配置變量即可,科科。。。 如果右擊工程時沒有build path 修改.project檔案,有的話忽略 <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>apache-tomcat-8.5.4-src</name> <comment></comment> <projects> </projects> <buildSpec> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription> 主要是添加org.eclipse.jdt.core.javanature,要不然找不到build path,jar包也加不進來 啟動 找到java/org.apache.catalina.startup/Bootstrap.java檔案,右擊->run as->run configurations->在java application裡選擇start-tomcat(自動生成的)  錯誤log如下: 九月 20, 2016 12:21:13 下午 org.apache.catalina.startup.CatalinaProperties loadProperties警告: Failed to load catalina.properties九月 20, 2016 12:21:13 下午 org.apache.catalina.startup.Catalina load警告: Unable to load server configuration from [/Users/jikuan.zjk/Documents/workspace/tomcat-8.5.x/output/build/conf/server.xml]九月 20, 2016 12:21:13 下午 org.apache.catalina.startup.Catalina load警告: Unable to load server configuration from [/Users/jikuan.zjk/Documents/workspace/tomcat-8.5.x/output/build/conf/server.xml]九月 20, 2016 12:21:13 下午 org.apache.catalina.startup.Catalina start嚴重: Cannot start server. Server instance is not configured. 可見是在output檔案加下找到build/conf/server.xml檔案,output是ant編譯時候編譯出來的,在源碼檔案夾下是有個conf檔案夾的,裡面有server.xml  在output檔案夾下建立build/conf/并把server.xml複制進去  重新啟動,OK,啟動成功 資訊: Server startup in 176 ms 現在啟動時沒問題了,但是還不可以對外提供服務

繼續閱讀