这个星期接到一个新的任务:解决HQ(一个用JAVA开发的开源的运维监控平台)如今遇到的snmp升级到3.0后bug。公司用的HQ是4.6版本。因而,我把项目从gitlab上clone下来后,就开始了个人填坑之旅。坑了几天坑,到目前,正常状况,应该只有最后一个坑了,应该是关于tomcat运行环境的。闲话很少说,开始填坑之旅……java
项目maven build坑:mysql
clean compile install -Dmaven.javadoc.skip=true -DCI-build -Dall-installers -Dmaven.test.skip=true -e
解释一下吧,用maven.javadoc.skip=true是由于项目中的注释,有太多太可能是不符合javadoc规范的,因此若是编译javadoc的话,会出现一推警告,而后编译失败。git
assembly.xml:github
pom.xmlweb
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin>
OK,到如今为止,我遇到的maven的build坑基本差很少了。通过上面的改造后,个人hq项目可以install成功了。不过,install成功后,本地运行hq-web项目时,遇到的坑,深坑,比build过程要艰难的多,在这里我也记录一下,与君共勉。sql
hq-web 项目运行遇到的坑:apache
Add the following properties to ~/.hq/build.properties to connect the schema installer, hq-web app, or integration tests to your DB: server.database-url=jdbc:mysql://localhost:3306/hqdb server.database-driver=com.mysql.jdbc.Driver server.database=MySQL server.database-user=hq server.database-password=hq server.admin.username=hqadmin server.admin.password=hqadmin
生成hyperic.keystore 证书的密码为:hyperic(记住,这个证书密码必须是这个,否则会出错),由于我是想进行项目的debug,因此我修改了源码中对证书路径的校验代码,让我能够指定证书的文件路径,经过jvm的运行参数:文件为:org.hyperic.hq.security.ServerKeystoreConfig:68tomcat
// ...make sure this exists if (!keystoreFile.exists()) { /** * 添加keystore path的自定义参数路径 */ String keystorePath = System.getProperty("yiji.hq.keystore.path"); if(keystorePath != null){ keystoreFile = new File(keystorePath); if(!keystoreFile.exists()){ throw new ConfigPropertyException("The keystore path [" + keystoreFile.getPath() + "] does not exist. If setting a relative path, it must be relative to the server's hq-server directory."); } } // throw new ConfigPropertyException("The keystore path [" + keystoreFile.getPath() + "] does not exist. If setting a relative path, it must be relative to the server's hq-server directory."); }
keytool -genkeypair -alias "test1" -keyalg "RSA" -keystore "test.keystore"
-Dyiji.hq.keystore.path=/Users/QianL/Desktop/hyperic.keystore -server -Xms1024m -Xmx2048m -XX:PermSize=512M -XX:MaxNewSize=1024m -XX:MaxPermSize=1024m
我通过上面的折腾后,项目就能够经过IDEA进行tomcat debug运行调试了。服务器
其实项目的坑远不止这些,不如若是使用tomcat插件运行的,还会报 sigar包找不到本地的动态库文件 和 找不到 hq-plugins 插件目录的异常,不过若是是经过我上面的那种运行方式,这两个以上我都没有遇到了。app
后面有时间我也把官方目前最新的HQ5.8的build 成功的经验写上来。