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 阅读(3529) 评论(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">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">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。  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 
<2007年2月>
28293031123
45678910
11121314151617
18192021222324
25262728123
45678910

导航

统计

公告

主要记录作者在学习java中的每一步足迹。除非特别说明,所有文章均为本blog作者原创,如需转载请注明出处和原作者,如用于商业目的,需跟作者本人联系。
欢迎大家访问:

常用链接

留言簿(16)

随笔分类

随笔档案

文章分类

文章档案

相册

收藏夹

java技术

人间百态

朋友们的blog

搜索

最新评论

阅读排行榜

评论排行榜