openfans快速配置指南

          應牛牛和 lucky 的要求,寫一份 openfans 的快速配置指南,也就是介紹如何在你的機器上把下載下來的 openfans 跑起來。首先使用 maven ,需要下載 maven www.openfans.net 里可以輸入 maven 進行搜索,有它的介紹和主頁,還有我寫的一篇簡單的 maven 上手文章。

          如果使用 eclipse ,在項目根目錄,也就是 pom.xml 所在目錄,運行 mvn eclipse:eclipse( 如初次使用,會花較長時間到網上下載 plugin jar ,建議去喝杯咖啡 ) mvn eclipse:eclipse 會生成 .class .project 文件,可以進入項目的 build path 查看,會自動將 output 路徑設為 target/classes 。默認數據庫使用 mysql ,如果希望馬上運行,則創建一個新數據庫,可以命名為 openfans ,如果 mysql 采用默認安裝,則用戶名 root ,密碼為空,可以無需更改 jdbc 配置文件。要更改也很簡單,在 main/src 下面有一個 jdbc.properties 文件,可以在這里更改數據庫類型和用戶名密碼。這里有一句 hibernate.hbm2ddl.auto=update ,表示 hibernate 會自動更新建表語句,也就是新運行或更新了 hbm 文件再運行, hibernate 都會自動幫你完成數據表的重建工作,這樣你可以不用再考慮數據庫建表腳本了。

          如果想在 tomcat 里直接運行,則可以執行 mvn package ,會運行所有 test case 。目前的 test case 通過繼承 AbstractTransactionalDataSourceSpringContextTests ,能夠方便的實現數據庫回滾,在 BaseTest 類下有一句 this.setDefaultRollback(false) ,如果希望通過程序填充數據,就 uncomment 它。這里有一個地方要注意一下,就是 web/WEB-INF/urlrewrite.xml ,這是 urlrewrite 的配置文件, urlrewrite 的描述在 openfans 網站里有,可以通過搜索 urlrewrite 快速的找到。因為我把文檔根設為“ / ”,所以有 <to type="redirect">/view$1.html\?id=$2</to> ,如果文檔根是 openfans 則需在 /view 前加上 /openfans ,然后再運行 mvn package 。測試全部通過,就會在 target 目錄下生成 openfans-o.1.war ,將這個 war 放到 tomcat webapps 下,啟動 tomcat ,應該就能通過 http://localhost:8080/openfans 訪問了(假定你采用默認端口 8080 )。

          如果進行開發,可以安裝 eclipse-tomcat 插件,插件也可以在 openfans 網站輸入 tomcat 進行搜索。可以在 tomcat conf/Catalina/localhost 下創建一個 openfans.xml ,內容如下:

          <?xml version="1.0" encoding="UTF-8"?>

          <Context path="/openfans" reloadable="true" docBase="D:/javaproject/openfans/web">

          </Context>

          docBase 改成你的 openfans 所在的路徑。
          ???這里因為pom文件定義的默認輸出位置為target,需改為web-inf/classes,這時會有一個src沖突,需把src/web/里的web-inf/classes exclude掉就可以了。
          然后在
          eclipse 啟動 tomcat ,同樣可以通過 http://localhost:8080/openfans 訪問了。用這種方式啟動 tomcat 可以進行調試。

          ?

          posted on 2006-04-01 21:05 pesome 閱讀(3545) 評論(11)  編輯  收藏 所屬分類: 開源軟件

          評論

          # re: openfans快速配置指南 2006-04-11 17:49 莫多

          mvn eclipse:eclipse就不能通過。
          D:\Project\openfans>mvn eclipse:eclipse
          [INFO] Scanning for projects...
          [INFO] Searching repository for plugin with prefix: 'eclipse'.
          [INFO] -------------------------------------------------------------------------
          ---
          [INFO] Building openfans
          [INFO] task-segment: [eclipse:eclipse]
          [INFO] -------------------------------------------------------------------------
          ---
          [INFO] Preparing eclipse:eclipse
          [INFO] [resources:resources]
          [INFO] Using default encoding to copy filtered resources.
          [WARNING]
          Artifact javax.servlet:jstl:jar:1.1.2:runtime retains local scope 'runti
          me' overriding broader scope 'compile'
          given by a dependency. If this is not intended, modify or remove the loc
          al scope.

          [WARNING]
          Artifact jdom:jdom:jar:1.0:runtime retains local scope 'runtime' overrid
          ing broader scope 'compile'
          given by a dependency. If this is not intended, modify or remove the loc
          al scope.

          [WARNING]
          Artifact taglibs:standard:jar:1.1.2:runtime retains local scope 'runtime
          ' overriding broader scope 'compile'
          given by a dependency. If this is not intended, modify or remove the loc
          al scope.

          [INFO] [compiler:compile]
          [INFO] Nothing to compile - all classes are up to date
          [INFO] [eclipse:eclipse]
          [WARNING] This plugin currently doesn't support include patterns for resources.
          Adding the entire directory.
          [WARNING] This plugin currently doesn't support include patterns for resources.
          Adding the entire directory.
          [INFO] Not writing settings - defaults suffice
          [INFO]
          Sources for some artifacts are not available.
          Please run "mvn -Declipse.downloadSources=true eclipse:eclipse" in order
          to check remote repositories for sources.
          List of artifacts without a source archive:
          o org.springframework:spring-mock:jar:1.2.6
          o junit:junit:jar:3.8.1
          o commons-logging:commons-logging:jar:1.0.4
          o javax.servlet:servlet-api:jar:2.4
          o commons-digester:commons-digester:jar:1.5
          o geronimo-spec:geronimo-spec-jta:jar:1.0.1B-rc4
          o uk.ltd.getahead:dwr:jar:1.0
          o org.springframework:spring:jar:1.2.6
          o opensymphony:sitemesh:jar:2.2.1
          o com.lowagie:itext:jar:0.99
          o commons-validator:commons-validator:jar:1.1.3
          o javax.servlet:jstl:jar:1.1.2
          o asm:asm:jar:1.5.3
          o commons-dbcp:commons-dbcp:jar:1.2.1
          o jdom:jdom:jar:1.0
          o taglibs:standard:jar:1.1.2
          o oro:oro:jar:2.0.8
          o antlr:antlr:jar:2.7.6rc1
          o commons-beanutils:commons-beanutils:jar:1.6.1
          o commons-io:commons-io:jar:1.1
          o org.tuckey:urlrewrite:jar:2.5.2
          o xerces:xercesImpl:jar:2.0.2
          o p6spy:p6spy:jar:1.3
          o rome:rome:jar:0.8
          o commons-fileupload:commons-fileupload:jar:1.1
          o mysql:mysql-connector-java:jar:3.1.11
          o org.hibernate:hibernate:jar:3.1
          o displaytag:displaytag:jar:1.0
          o dom4j:dom4j:jar:1.6
          o cglib:cglib:jar:2.1_3
          o ehcache:ehcache:jar:1.1
          o commons-lang:commons-lang:jar:2.0
          o commons-collections:commons-collections:jar:2.1.1
          o springmodules:springmodules-validator:jar:0.1
          o log4j:log4j:jar:1.2.11
          o xml-apis:xml-apis:jar:1.0.b2
          o commons-pool:commons-pool:jar:1.2

          [INFO] Wrote Eclipse project for "openfans" to D:\Project\openfans.
          [INFO] ------------------------------------------------------------------------
          [INFO] BUILD SUCCESSFUL
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 8 seconds
          [INFO] Finished at: Tue Apr 11 17:43:11 GMT+08:00 2006
          [INFO] Final Memory: 4M/8M
          [INFO] ------------------------------------------------------------------------
            回復  更多評論   

          # re: openfans快速配置指南 2006-04-11 17:50 莫多

          然后按照上面說的。運行mvn -Declipse.downloadSources=true eclipse:eclipse
          又抱錯誤找不到。
          [INFO] [compiler:compile]
          [INFO] Nothing to compile - all classes are up to date
          [INFO] [eclipse:eclipse]
          [WARNING] This plugin currently doesn't support include patterns for resources.
          Adding the entire directory.
          [WARNING] This plugin currently doesn't support include patterns for resources.
          Adding the entire directory.
          Downloading: http://www.ibiblio.org/maven2/org/springframework/spring-mock/1.2.6
          /spring-mock-1.2.6-sources.jar
          [WARNING] Unable to get resource from repository central (http://www.ibiblio.org
          /maven2)
          Downloading: http://www.openfans.org:81/maven2/org/springframework/spring-mock/1
          .2.6/spring-mock-1.2.6-sources.jar
          [INFO] ------------------------------------------------------------------------
          [ERROR] BUILD ERROR
          [INFO] ------------------------------------------------------------------------
          [INFO] Failed to resolve artifact.

          Error transferring file
          org.springframework:spring-mock:java-source:1.2.6

          from the specified remote repositories:
          central (http://www.ibiblio.org/maven2),
          openfans (http://www.openfans.org:81/maven2)


          Caused by I/O exception: Connection refused: connect

          [INFO] ------------------------------------------------------------------------
          [INFO] For more information, run Maven with the -e switch
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 10 seconds
          [INFO] Finished at: Tue Apr 11 17:45:56 GMT+08:00 2006
          [INFO] Final Memory: 4M/8M
          [INFO] ------------------------------------------------------------------------  回復  更多評論   

          # re: openfans快速配置指南 2006-04-11 19:09 pesom

          warning沒有太多關系,都報BUILD SUCCESSFUL 了,呵呵!
          mvn -Declipse.downloadSources=true eclipse:eclipse作用是將遠程的src下載到本地的repo中,同時自動幫你在項目中加載這些src,讓你可以直接在eclipse中查看源文件,而不用去自己綁定src。
          Caused by I/O exception: Connection refused: connect 這種情況經常會碰到,可能是jar較大,導致的網絡問題,可以重試。  回復  更多評論   

          # re: openfans快速配置指南 2006-12-18 19:18 wujianrong

          我使用mvn package的時候出錯;煩請給我發一份openfans的源碼到citycn@gmail.com,謝謝!  回復  更多評論   

          # re: openfans快速配置指南 2006-12-18 19:23 pesome

          源碼就在sf上的啊,我現在也沒有最新的了  回復  更多評論   

          # re: openfans快速配置指南[未登錄] 2007-02-09 10:51 rose

          I:\openfans>mvn package
          [INFO] Scanning for projects...
          [INFO] ----------------------------------------------------------------------------
          [INFO] Building openfans
          [INFO] task-segment: [package]
          [INFO] ----------------------------------------------------------------------------
          [INFO] [resources:resources]
          [INFO] Using default encoding to copy filtered resources.
          [WARNING]
          Artifact javax.servlet:jstl:jar:1.1.2:runtime retains local scope 'runtime' overriding broa
          er scope 'compile'
          given by a dependency. If this is not intended, modify or remove the local scope.

          [WARNING]
          Artifact taglibs:standard:jar:1.1.2:runtime retains local scope 'runtime' overriding broade
          scope 'compile'
          given by a dependency. If this is not intended, modify or remove the local scope.

          [INFO] [compiler:compile]
          Compiling 68 source files to I:\openfans\target\classes
          [INFO] [resources:testResources]
          [INFO] Using default encoding to copy filtered resources.
          [INFO] [compiler:testCompile]
          Compiling 7 source files to I:\openfans\target\test-classes
          [INFO] [surefire:test]
          [INFO] Surefire report directory: I:\openfans\target\surefire-reports

          -------------------------------------------------------
          T E S T S
          -------------------------------------------------------
          Running org.openfans.feed.FeedManagerTest
          2007-02-09 10:48:06234 INFO - AbstractSpringContextTests.loadContextLocations(119) | Loading config
          for: /WEB-INF/applicationContext*.xml
          Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.375 sec <<< FAILURE!
          Running org.openfans.domain.TagRelTest
          Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.141 sec <<< FAILURE!
          Running org.openfans.domain.GroupTest
          Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.141 sec <<< FAILURE!
          Running org.openfans.domain.TagTest
          Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
          Running org.openfans.domain.FacadeTest
          Tests run: 4, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 0.281 sec <<< FAILURE!

          Results :
          Tests run: 10, Failures: 0, Errors: 9, Skipped: 0

          [INFO] ------------------------------------------------------------------------
          [ERROR] BUILD FAILURE
          [INFO] ------------------------------------------------------------------------
          [INFO] There are test failures.
          [INFO] ------------------------------------------------------------------------
          [INFO] For more information, run Maven with the -e switch
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 5 seconds
          [INFO] Finished at: Fri Feb 09 10:48:07 CST 2007
          [INFO] Final Memory: 5M/17M
          [INFO] ------------------------------------------------------------------------


          無法成功打包哦。。

          搞了N 次了。。  回復  更多評論   

          # re: openfans快速配置指南 2007-02-09 11:20 pesome

          現在新的源碼已經放到googlecode上了,wiki里有新的介紹。這里需使用mvn package -Dtest,不做test。主要是測試沒寫好,呵呵,抱歉!  回復  更多評論   

          # re: openfans快速配置指南 2007-02-09 11:20 pesome

          忘了,http://code.google.com/p/openfans2  回復  更多評論   

          # re: openfans快速配置指南 2007-06-15 14:29 飛影

          我的報下面這個錯誤:

          [INFO] Scanning for projects...
          [INFO] ----------------------------------------------------------------------------
          [INFO] Building openfans
          [INFO] task-segment: [package]
          [INFO] ----------------------------------------------------------------------------
          Downloading: http://repo1.maven.org/maven2/org/mortbay/jetty/org.mortbay.jetty/5.1.10/org.mortbay.jetty-5.1.10.pom
          [INFO] [aspectj:compile {execution: default}]
          [INFO] [resources:resources]
          [INFO] Using default encoding to copy filtered resources.
          [INFO] [compiler:compile]
          [INFO] Compiling 4 source files to D:\IDE\Workspace\openfans2\target\classes
          [INFO] ------------------------------------------------------------------------
          [ERROR] BUILD FAILURE
          [INFO] ------------------------------------------------------------------------
          [INFO] Compilation failure

          D:\IDE\Workspace\openfans2\main\src\org\openfans\web\ArticleFormController.java:[53,36] 未結束的字符串字面值

          D:\IDE\Workspace\openfans2\main\src\org\openfans\feed\FeedRetriever.java:[129,35] 未結束的字符串字面值

          D:\IDE\Workspace\openfans2\main\src\org\openfans\feed\FeedRetriever.java:[131,35] 未結束的字符串字面值

          D:\IDE\Workspace\openfans2\main\src\org\openfans\web\FeedBackFormController.java:[37,19] 未結束的字符串字面值

          D:\IDE\Workspace\openfans2\main\src\org\openfans\feed\FeedManager.java:[84,50] 未結束的字符串字面值


          [INFO] ------------------------------------------------------------------------
          [INFO] For more information, run Maven with the -e switch
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 4 seconds
          [INFO] Finished at: Fri Jun 15 14:22:35 CST 2007
          [INFO] Final Memory: 6M/11M
          [INFO] ------------------------------------------------------------------------
            回復  更多評論   

          # re: openfans快速配置指南 2008-12-12 17:26 為啥真么不規范呢

          我和飛影報的錯誤一樣,我使用的是netbeans6.1,用的JDK是6.2  回復  更多評論   

          # re: openfans快速配置指南 2008-12-12 18:00 為啥真么不規范呢

          編碼格式很混亂啊,一會UTF-8,一會GBK。  回復  更多評論   

          <2006年4月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          導航

          統計

          公告

          主要記錄作者在學習java中的每一步足跡。除非特別說明,所有文章均為本blog作者原創,如需轉載請注明出處和原作者,如用于商業目的,需跟作者本人聯系。
          歡迎大家訪問:

          常用鏈接

          留言簿(16)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          java技術

          人間百態

          朋友們的blog

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 平罗县| 南投市| 喜德县| 宣化县| 资阳市| 云梦县| 阳高县| 衡水市| 文水县| 搜索| 德格县| 富源县| 绥阳县| 营山县| 五大连池市| 临夏市| 铜山县| 日土县| 渝北区| 浮梁县| 萨迦县| 密山市| 云浮市| 南郑县| 南皮县| 苍南县| 南岸区| 长沙市| 大方县| 边坝县| 子长县| 山丹县| 白银市| 吉木乃县| 化隆| 边坝县| 民县| 泗洪县| 宝应县| 石景山区| 岗巴县|