源码下载
下载源码,直接下载最新release版本4.5.3源码。尽可能不要改动源码,否则后续版本升级会带来很大的困难,需要的一些自定义特性以插件的形式去开发,后续版本升级就非常容易。
https://github.com/igniterealtime/Openfire/archive/v4.5.3.tar.gz
idea源码导入与构建
直接import,选择有父pom的根目录,一直next就可以了。导入后,设置jdk编译版本等。最后maven clean package
把项目构建下,网络情况不好的话,可能会出现一些jar包下载失败,这时只需要把相关坐标的文件清理,重新构建。
构建成功后发现maven-gpg-plugin
和maven-javadoc-plugin
这两个插件报错,原因是在构建时没下载到这两个插件。只需要把这两个插件的maven依赖找个pom放一下,让idea去下载,下载完就把代码去掉,这样就不报错了。
启动程序
参考github openfire主页:https://github.com/igniterealtime/Openfire
To build the complete project including plugins, run the command
./mvnw verify
这一步直接用idea的maven verify,因为mvnw相当于openfire自带的maven,可能跟我们项目配置的不一样,所以直接在idea操作即可。打包完成会在openfire\Openfire-4.5.3\distribution\target\distribution-base
路径下生成部署安装包。
However much of the time it is only necessary to make changes to the core XMPP server itself in which case the command
./mvnw verify -pl distribution -am
这一步同样用idea去完成
-
Run -> Edit Configurations... -> Add Application
-
fill in following values
-
Name: Openfire
-
Use classpath of module: starter
-
Main class: org.jivesoftware.openfire.starter.ServerStarter
-
VM options (adapt accordingly):
-DopenfireHome="-absolute path to your project folder-\distribution\target\distribution-base" -Xverify:none -server -Dlog4j.configurationFile="-absolute path to your project folder-\distribution\target\distribution-base\lib\log4j2.xml" -Dopenfire.lib.dir="-absolute path to your project folder-\distribution\target\distribution-base\lib" -Dfile.encoding=UTF-8
-
Working directory: -absolute path to your project folder-
-
-
apply
-
You need to execute
mvnw verify
before you can launch openfire.
最后,直接在idea run或debug即可。启动时如果端口被占用,idea控制台并没打印造成了疑惑,找到日志文件去查看原因才发现。distribution-base
目录就是最终生成的程序安装包,可分别在linux或window中部署。通过openfire.xml
配置文件修改一下被占用的端口即可正常运行。
参考上面的安装部署文档去设置本地环境即可。启动后,会打印出admin监控地址,直接访问,后续操作和上面的安装部署一致,不再赘述。(账号:admin 密码:nufront,域、fqdn全部设置为www.test.com)
版本升级
版本升级到4.6.0,操作步骤与上面一致。