<legend id='uEXn8'><style id='uEXn8'><dir id='uEXn8'><q id='uEXn8'></q></dir></style></legend>

  • <small id='uEXn8'></small><noframes id='uEXn8'>

    1. <i id='uEXn8'><tr id='uEXn8'><dt id='uEXn8'><q id='uEXn8'><span id='uEXn8'><b id='uEXn8'><form id='uEXn8'><ins id='uEXn8'></ins><ul id='uEXn8'></ul><sub id='uEXn8'></sub></form><legend id='uEXn8'></legend><bdo id='uEXn8'><pre id='uEXn8'><center id='uEXn8'></center></pre></bdo></b><th id='uEXn8'></th></span></q></dt></tr></i><div id='uEXn8'><tfoot id='uEXn8'></tfoot><dl id='uEXn8'><fieldset id='uEXn8'></fieldset></dl></div>
    2. <tfoot id='uEXn8'></tfoot>
        <bdo id='uEXn8'></bdo><ul id='uEXn8'></ul>

        从我的 java 程序调用声纳

        时间:2024-05-09

          <small id='uhAj3'></small><noframes id='uhAj3'>

          <i id='uhAj3'><tr id='uhAj3'><dt id='uhAj3'><q id='uhAj3'><span id='uhAj3'><b id='uhAj3'><form id='uhAj3'><ins id='uhAj3'></ins><ul id='uhAj3'></ul><sub id='uhAj3'></sub></form><legend id='uhAj3'></legend><bdo id='uhAj3'><pre id='uhAj3'><center id='uhAj3'></center></pre></bdo></b><th id='uhAj3'></th></span></q></dt></tr></i><div id='uhAj3'><tfoot id='uhAj3'></tfoot><dl id='uhAj3'><fieldset id='uhAj3'></fieldset></dl></div>
            <bdo id='uhAj3'></bdo><ul id='uhAj3'></ul>
            <tfoot id='uhAj3'></tfoot>
              <tbody id='uhAj3'></tbody>

              <legend id='uhAj3'><style id='uhAj3'><dir id='uhAj3'><q id='uhAj3'></q></dir></style></legend>

                  本文介绍了从我的 java 程序调用声纳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经在我的本地主机上安装了声纳服务器.而且我能够运行和分析java项目.即使我已经在 Eclipse 上安装了声纳插件.

                  I have installed sonar server on my localhost. And I am able to run and analyse the java project. Even i have installed sonar plugin on eclipse.

                  但我想从我的 java 项目(如简单的 java 类)中运行声纳,并且应该检索声纳结果并能够将其保存在数据库中.我搜索了教程,但找不到答案.请任何人都可以提供示例代码或资源,我可以从中获得知识来克服这项任务.

                  But I want to run sonar from my java project(like simple java class) and should retrieve the sonar results and able to save it in database. I searched for the tutorial but unable to find the answer for this. Please anyone can give sample code or resource where I can gain knowledge to overcome this task.

                  import javax.annotation.Resource;
                  
                  
                  import org.sonar.wsclient.Host;
                  import org.sonar.wsclient.Sonar;
                  import org.sonar.wsclient.connectors.HttpClient4Connector;
                  import org.sonar.wsclient.services.*;
                  
                  public class SonarTask1{
                  
                  public static void main(String[] args) {
                      //public void Hi(){
                      String url = "http://localhost:9000";
                      String login = "admin";
                      String password = "admin";
                      Sonar sonar = new Sonar(new HttpClient4Connector(new Host(url, login, password)));
                  
                      String projectKey = "java-sonar-runner-simple";
                      String manualMetricKey = "burned_budget";
                  
                      sonar.create(ManualMeasureCreateQuery.create(projectKey, manualMetricKey).setValue(50.0));
                  
                      for (ManualMeasure manualMeasure : sonar.findAll(ManualMeasureQuery.create(projectKey))) {
                        System.out.println("Manual measure on project: " + manualMeasure);
                      }
                    }
                  
                  }
                  

                  推荐答案

                  您可以通过 Java 程序做两件事:

                  There are 2 things you can do from a Java program:

                  • 启动声纳分析:查看 Sonar Ant 任务(在方法#launchAnalysis 中)了解如何轻松完成.

                  • launch a Sonar analysis: look into the Sonar Ant Task (in method #launchAnalysis) to see how to do that very easily.

                  从 Sonar 服务器检索结果:检查 Web API 为此目的

                  retrieve results from the Sonar server: check the Web API for that purpose

                  这篇关于从我的 java 程序调用声纳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:将 JaCoCo 与 SONAR 集成以实现单元和集成测试覆盖率 下一篇:使这一行开始于第 9 列声纳违规修复(源代码应一致缩进)

                  相关文章

                      <bdo id='59Yhm'></bdo><ul id='59Yhm'></ul>
                    <tfoot id='59Yhm'></tfoot>

                    <small id='59Yhm'></small><noframes id='59Yhm'>

                      <legend id='59Yhm'><style id='59Yhm'><dir id='59Yhm'><q id='59Yhm'></q></dir></style></legend>

                      <i id='59Yhm'><tr id='59Yhm'><dt id='59Yhm'><q id='59Yhm'><span id='59Yhm'><b id='59Yhm'><form id='59Yhm'><ins id='59Yhm'></ins><ul id='59Yhm'></ul><sub id='59Yhm'></sub></form><legend id='59Yhm'></legend><bdo id='59Yhm'><pre id='59Yhm'><center id='59Yhm'></center></pre></bdo></b><th id='59Yhm'></th></span></q></dt></tr></i><div id='59Yhm'><tfoot id='59Yhm'></tfoot><dl id='59Yhm'><fieldset id='59Yhm'></fieldset></dl></div>