Hi,大家好,我是编程小6,很荣幸遇见你,我把这些年在开发过程中遇到的问题或想法写出来,今天说一说sonar入门,希望能够帮助你!!!。
http://www.sonarqube.org/downloads/
我下载的是最新版本sonarqube-5.1.2.zip
unzip sonarqube-5.1.2.zip
推荐使用mysql(默认会使用sonar内置的数据库)
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
vi HOME/.bash_profile
PATH= PATH: HOME/bin
SONAR_HOME=$HOME/sonar
export PATH SONAR_HOME
source $HOME/.bash_profile
{SONAR_HOME}/bin/linux-x86-64/sonar.sh start 或者
C:\work\sonarqube-5.1.2\sonarqube-5.1.2\bin\windows-x86-32\StartSonar.bat(见下面)
http://localhost:9000/
vi {SONAR_HOME}/conf/sonar.properties
http://docs.codehaus.org/display/SONAR/Plugin+Library
set MAVEN_OPTS=”-Xmx512m -XX:MaxPermSize=256m”
mvn sonar:sonar
第一次会自动在sonar库中建表,插入初始化数据。
WrapperSimpleApp: Unable to locate the class org.sonar.application.App: java.lang.UnsupportedClassVersionError: org/sonar/application/App : Unsupported major.minor version 51.0
解决方法:
cd sonarqube-5.1.2/conf
vi wrapper.conf
linux:
wrapper.java.command=/opt/jdk1.7.0_80/bin/java
windows:
wrapper.java.command=C:\Documents and Settings\Administrator\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_1.7.0.u45\bin\java
参考:http://docs.sonarqube.org/display/SONAR/Requirements
Unsupported major.minor version 51.0
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7:sonar (default-cli) on project zsale-web: Execution default-cli of goal org.codehaus.mojo:sonar-maven-plugin:2.7:sonar failed: Unable to load the mojo ‘sonar’ in the plugin ‘org.codehaus.mojo:sonar-maven-plugin:2.7’ due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/codehaus/mojo/sonar/SonarMojo : Unsupported major.minor version 51.0
[ERROR] —————————————————–
[ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:2.7
解决方法:
windows:
把path的jdk改为java7,并且重启cmd!(很重要),就可以了
linux:
vi .bash_profile
JAVA_HOME=/opt/jdk1.7.0_80
export JAVA_HOME
PATH= JAVAHOME/bin: PATH
export PATH
source $HOME/.bash_profile
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7:sonar (default-cli) on project zsale-web: Fail to connect to database: Cannot load JDBC driver class ‘com.mysql.jdbc.Driver’ -> [Help 1]
解决方法:
把settings.xml里的mysql的配置去掉就成功了
或者:
vi sonar.properties
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
改完要重启?
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar(default-cli) on project zsale-web: Fail to connect to database: Cannot load JDBC driver class ‘org.h2.Driver’ -> [Help 1]
解决方法:
settings.xml里也得配置数据库
cd apache-maven-3.2.5/conf
vi settings.xml
<profile>
<id>sonar</id>
<properties>
<sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar</sonar.jdbc.url>
<sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.host.url>http://localhost:9000</sonar.host.url>
</properties>
</profile>
pom.xml里的jdk可以为1.6
默认密码是admin/admin,保存在表users
转载请标明出处:
本文出自:【ouyida3的博客】
2015.11.5
今天的分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。
上一篇
已是最后文章
下一篇
已是最新文章