openfans快速配置指南

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

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

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

          如果進(jìn)行開發(fā),可以安裝 eclipse-tomcat 插件,插件也可以在 openfans 網(wǎng)站輸入 tomcat 進(jìn)行搜索。可以在 tomcat conf/Catalina/localhost 下創(chuàng)建一個(gè) openfans.xml ,內(nèi)容如下:

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

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

          </Context>

          docBase 改成你的 openfans 所在的路徑。
          ???這里因?yàn)閜om文件定義的默認(rèn)輸出位置為target,需改為web-inf/classes,這時(shí)會(huì)有一個(gè)src沖突,需把src/web/里的web-inf/classes exclude掉就可以了。
          然后在
          eclipse 啟動(dòng) tomcat ,同樣可以通過 http://localhost:8080/openfans 訪問了。用這種方式啟動(dòng) tomcat 可以進(jìn)行調(diào)試。

          ?

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

          評(píng)論

          # 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] ------------------------------------------------------------------------
            回復(fù)  更多評(píng)論   

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

          然后按照上面說的。運(yùn)行mvn -Declipse.downloadSources=true eclipse:eclipse
          又抱錯(cuò)誤找不到。
          [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] ------------------------------------------------------------------------  回復(fù)  更多評(píng)論   

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

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

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

          我使用mvn package的時(shí)候出錯(cuò);煩請(qǐng)給我發(fā)一份openfans的源碼到citycn@gmail.com,謝謝!  回復(fù)  更多評(píng)論   

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

          源碼就在sf上的啊,我現(xiàn)在也沒有最新的了  回復(fù)  更多評(píng)論   

          # 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 次了。。  回復(fù)  更多評(píng)論   

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

          現(xiàn)在新的源碼已經(jīng)放到googlecode上了,wiki里有新的介紹。這里需使用mvn package -Dtest,不做test。主要是測(cè)試沒寫好,呵呵,抱歉!  回復(fù)  更多評(píng)論   

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

          忘了,http://code.google.com/p/openfans2  回復(fù)  更多評(píng)論   

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

          我的報(bào)下面這個(gè)錯(cuò)誤:

          [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] 未結(jié)束的字符串字面值

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

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

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

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


          [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] ------------------------------------------------------------------------
            回復(fù)  更多評(píng)論   

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

          我和飛影報(bào)的錯(cuò)誤一樣,我使用的是netbeans6.1,用的JDK是6.2  回復(fù)  更多評(píng)論   

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

          編碼格式很混亂啊,一會(huì)UTF-8,一會(huì)GBK。  回復(fù)  更多評(píng)論   

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

          導(dǎo)航

          統(tǒng)計(jì)

          公告

          主要記錄作者在學(xué)習(xí)java中的每一步足跡。除非特別說明,所有文章均為本blog作者原創(chuàng),如需轉(zhuǎn)載請(qǐng)注明出處和原作者,如用于商業(yè)目的,需跟作者本人聯(lián)系。
          歡迎大家訪問:

          常用鏈接

          留言簿(16)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊(cè)

          收藏夾

          java技術(shù)

          人間百態(tài)

          朋友們的blog

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 青龙| 蒙城县| 兴文县| 达拉特旗| 中西区| 洪泽县| 台前县| 巴中市| 博白县| 左权县| 新竹市| 广宁县| 汝城县| 固镇县| 繁峙县| 九龙县| 泰安市| 林芝县| 莆田市| 台湾省| 扎赉特旗| 东兰县| 山东| 望江县| 新余市| 马山县| 宜兰县| 嘉峪关市| 永嘉县| 湘潭市| 安乡县| 西昌市| 乌苏市| 酒泉市| 米林县| 乐业县| 德惠市| 称多县| 应城市| 平乡县| 黔东|