sonar+maven2使用说明(最终版)_第1页
sonar+maven2使用说明(最终版)_第2页
sonar+maven2使用说明(最终版)_第3页
sonar+maven2使用说明(最终版)_第4页
sonar+maven2使用说明(最终版)_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、一、sonar环境搭建1、安装JDK-1.5以上版本。在环境变量中配置JAVA_HOME,并在path里添加%JAVA_HOME%bin;2、安装mysql-5.x以上版本。3、mysql新建数据库并增加权限CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;GRANT all ON sonar.* TO sonarlocalhost IDENTIFIED BY sonar;FLUSH PRIVILEGES ;4、在sonar官网上下载并解压sonar-2.8.zip,不要放在中文

2、目录下。5、配置perties文件:1)配置启动的http端口sonar.web.host: localhostsonar.web.port: 9000sonar.web.context: /三句前本来被注释,取消注释2)注释掉Derby数据库绑定(49、50行)#sonar.jdbc.url: jdbc:derby:/localhost:1527/sonar;create=true#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver3)取消mysql连接的注释#- MySQL

3、 5.x/6.x# Comment the embedded database and uncomment the following properties to use MySQL. The validation query is optional.sonar.jdbc.url: jdbc:mysql:/localhost:3306/sonar?useUnicode=true&characterEncoding=utf8sonar.jdbc.driverClassName: com.mysql.jdbc.Driversonar.jdbc.validationQuery: select

4、 1运行sonar-2.8binwindows-x86-32StartSonar.bat,打开相应的网页:http:/localhost:9000测试是否配置成功,这里的页面链接跟前头的http配置有关第三条,也就是说,把perties 文件修改成以下内容:# Listen host/port and context path (for example / or /sonar). Default values are localhost:9000/.sonar.web.host: localhostsonar.web.port: 9000sonar.web.context:

5、/sonar.jdbc.username: sonarsonar.jdbc.password: sonar#- MySQL 5.x/6.x# Comment the embedded database and uncomment the following properties to use MySQL. The validation query is optional.sonar.jdbc.url: jdbc:mysql:/localhost:3306/sonar?useUnicode=true&characterEncoding=utf8sonar.jdbc.driverClass

6、Name: com.mysql.jdbc.Driversonar.jdbc.validationQuery: select 1#- Connection pool settingssonar.jdbc.maxActive: 10sonar.jdbc.maxIdle: 5sonar.jdbc.minIdle: 2sonar.jdbc.maxWait: 5000sonar.jdbc.minEvictableIdleTimeMillis: 600000sonar.jdbc.timeBetweenEvictionRunsMillis: 30000二、maven环境搭建 1、到maven官网http:/

7、/download.html去下载maven2.x版本。解压文件到非中文目录下。 2、配置MAVEN_HOME环境变量,在path里添加%MAVEN_HOME%bin;在命令行输入mvn h测试MAVEN环境是否配置正确。配置正确后,开始使用。三、maven+sonar测试1、在%MAVEN_HOME%confsetting.xml中输入下面内容(直接用下面的内容覆盖原文件): <?xml version="1.0" encoding="UTF-8"?><settings xmlns="http

8、://SETTINGS/1.0.0" xmlns:xsi="/2001/XMLSchema-instance" xsi:schemaLocation="/SETTINGS/1.0.0 /xsd/settings-1.0.0.xsd"> <profiles> <profile> <id>sonar</id> <activation>

9、 <activeByDefault>true</activeByDefault> </activation> <properties> <!- EXAMPLE FOR MYSQL -> <sonar.jdbc.url> jdbc:mysql:/localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8 </sonar.jdbc.url> <sonar.jdbc.driverClassName>com.mysql.jdbc.D

10、river</sonar.jdbc.driverClassName> <sonar.jdbc.username>sonar</sonar.jdbc.username> <sonar.jdbc.password>sonar</sonar.jdbc.password> <!- SERVER ON A REMOTE HOST -> <sonar.host.url>http:/localhost:9000</sonar.host.url> </properties> </profile&g

11、t; </profiles></settings>2、在项目源文件夹下,创建pom.xml文件,输入以下内容:<project xmlns="/POM/4.0.0" xmlns:xsi="/2001/XMLSchema-instance" xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd"&

12、gt; <modelVersion>4.0.0</modelVersion> <groupId>com.maven</groupId><!-项目包路径-> <artifactId>maventest</artifactId><!-项目名称-> <name>mavensonar-test</name><!-maven项目显示名称-> <url></url> <version>mavens

13、onar-test1.1</version><!-版本信息-> <build> <sourceDirectory>src</sourceDirectory><!-项目文件目录-> <outputDirectory>bin</outputDirectory><!-项目文件相关class文件目录-> <testSourceDirectory>test</testSourceDirectory><!-测试类文件目录-> <testOutputDirec

14、tory>bin</testOutputDirectory><!-测试类相关class文件目录-> <resources><!-项目资源文件目录-> <resource> <mergeId>resource-0</mergeId> <directory>srcresources</directory> </resource> </resources> <testResources><!-测试资源文件目录-> <testResou

15、rce> <mergeId>resource-1</mergeId> <directory>testresources</directory> </testResource> </testResources> <plugins> <plugin><!解决覆盖率为0的问题-> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artif

16、actId> <version>2.3</version> <configuration> <includes> <include>*/*Test*.java</include> </includes> </configuration> </plugin><plugin><!解决不支持泛型问题-> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-c

17、ompiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin></plugins></build> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><!-字符集设置-> </properties> <dependencies> <dependency> <groupId>junit</groupId><!-单元测试依赖文件-> <artifactId>junit</artifactId> <version>3.8.1</version><!-单元测试版本-> <scope>test</scope> </depende

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论