sonar(3.5.1版本)扫描时,如果某个项目第一次扫描的时候出错导致扫描终止,但是在出错之前已经往数据库中写入了一些数据。之后再次运行扫描就会出错,提示信息如下:
Exception in thread "main" org.sonar.runner.RunnerException: javax.persistence.NonUniqueResultException: Expected single result, but got : [4175, 4176] at org.sonar.runner.Runner.delegateExecution(Runner.java:288) at org.sonar.runner.Runner.execute(Runner.java:151) at org.sonar.runner.Main.execute(Main.java:84) at org.sonar.runner.Main.main(Main.java:56) Caused by: javax.persistence.NonUniqueResultException: Expected single result, but got : [4175, 4176] at org.sonar.jpa.session.JpaDatabaseSession.getSingleResult(JpaDatabaseSession.java:218) at org.sonar.batch.components.TimeMachineConfiguration.buildProjectSnapshot(TimeMachineConfiguration.java:79) at org.sonar.batch.components.TimeMachineConfiguration.initPastSnapshots(TimeMachineConfiguration.java:57) at org.sonar.batch.components.TimeMachineConfiguration.<init>(TimeMachineConfiguration.java:53) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:532) at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:147) at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:348) at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:272) at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:370) at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56) at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64) at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91) at org.picocontainer.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:606) at org.picocontainer.DefaultPicoContainer.getComponents(DefaultPicoContainer.java:587) at org.sonar.api.platform.ComponentContainer.getComponentsByType(ComponentContainer.java:123) at org.sonar.api.batch.BatchExtensionDictionnary.completeBatchExtensions(BatchExtensionDictionnary.java:91) at org.sonar.api.batch.BatchExtensionDictionnary.getExtensions(BatchExtensionDictionnary.java:85) at org.sonar.api.batch.BatchExtensionDictionnary.getFilteredExtensions(BatchExtensionDictionnary.java:98) at org.sonar.api.batch.BatchExtensionDictionnary.select(BatchExtensionDictionnary.java:57) at org.sonar.api.batch.BatchExtensionDictionnary.selectMavenPluginHandlers(BatchExtensionDictionnary.java:65) at org.sonar.batch.scan.maven.MavenPluginsConfigurator.execute(MavenPluginsConfigurator.java:48) at org.sonar.batch.phases.Phases.execute(Phases.java:95) at org.sonar.batch.scan.ScanContainer.doStart(ScanContainer.java:147) at org.sonar.batch.bootstrap.Container.start(Container.java:72) at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:65) at org.sonar.batch.scan.ScanTask.scanRecursively(ScanTask.java:56) at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:49) at org.sonar.batch.bootstrap.TaskContainer.doStart(TaskContainer.java:188) at org.sonar.batch.bootstrap.Container.start(Container.java:72) at org.sonar.batch.bootstrap.TaskBootstrapContainer.executeTask(TaskBootstrapContainer.java:73) at org.sonar.batch.bootstrap.TaskBootstrapContainer.doStart(TaskBootstrapContainer.java:62) at org.sonar.batch.bootstrap.Container.start(Container.java:72) at org.sonar.batch.bootstrap.BootstrapContainer.doStart(BootstrapContainer.java:104) at org.sonar.batch.bootstrap.Container.start(Container.java:72) at org.sonar.batch.Batch.execute(Batch.java:106) at org.sonar.runner.internal.batch.Launcher.executeBatch(Launcher.java:69) at org.sonar.runner.internal.batch.Launcher.execute(Launcher.java:61) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.sonar.runner.Runner.delegateExecution(Runner.java:285) ... 3 more
此时如果把sonar.projectKey属性改一下,也是可以正常运行代码扫描的,不过数据库里面就永久存储了一些垃圾数据,并且计划好的projectKey也要被迫更换,比较别扭。
还有一个方法就是直接修改sonar的数据库,从数据库层面直接清除掉第一次扫描失败时写入的垃圾数据。
假设第一次扫描时,sonar.projectKey属性值为D01:Project1:java,则使用以下sql语句将垃圾数据删除掉:
delete from action_plans_reviews where action_plan_id in (select id from action_plans where project_id in (select id from projects where kee like 'D01:Project1:java%')); delete from action_plans where project_id in (select id from projects where kee like 'D01:Project1:java%'); delete from project_links where project_id in (select id from projects where kee like 'D01:Project1:java%'); delete from project_measures where project_id in (select id from projects where kee like 'D01:Project1:java%'); delete from review_comments where review_id in(select id from reviews where project_id in (select id from projects where kee like 'D01:Project1:java%')); delete from reviews where project_id in (select id from projects where kee like 'D01:Project1:java%'); delete from duplications_index where snapshot_id in(select id from snapshots where project_id in (select id from projects where kee like 'D01:Project1:java%')); delete from events where snapshot_id in(select id from snapshots where project_id in (select id from projects where kee like 'D01:Project1:java%')); delete from graphs where snapshot_id in(select id from snapshots where project_id in (select id from projects where kee like 'D01:Project1:java%')); delete from measure_data where snapshot_id in(select id from snapshots where project_id in (select id from projects where kee like 'D01:Project1:java%')); delete from project_measures where snapshot_id in(select id from snapshots where project_id in (select id from projects where kee like 'D01:Project1:java%')); delete from rule_failures where snapshot_id in(select id from snapshots where project_id in (select id from projects where kee like 'D01:Project1:java%')); delete from snapshot_sources where snapshot_id in(select id from snapshots where project_id in (select id from projects where kee like 'D01:Project1:java%')); delete from snapshots where project_id in (select id from projects where kee like 'D01:Project1:java%'); delete from projects where kee like 'D01:Project1:java%';
相关推荐
sonar-project.properties
《Fisher Sonar数据集与线性判别分析在分类中的应用》 Fisher Sonar数据集,全称为fisher_sonar或fishersonar,是机器学习领域中一个广泛使用的分类问题实例,主要应用于训练和测试算法的性能。这个数据集源自声纳...
UCI的一个数据集Sonar,已经用MATLAB转化为.mat数据文件了,在MATLAB里面可以直接load
《MATLAB格式的Sonar数据集详解及其在机器学习中的应用》 Sonar数据集,一个广泛用于机器学习和模式识别研究的经典数据集,已经处理为.mat格式,方便了研究者进行快速的数据加载和分析。这个数据集包含了60个特征,...
sonar数据集是初学机器学习常用的数据集之一,包括R、M两类,208个样本
而"sonar-project.pr"显然是`sonar-project.properties`的缩写,是SonarRunner执行时的重要配置文件。 在解压后的"sonar-runner-2.4"目录下,可能包括以下内容: 1. `bin/`:包含启动SonarRunner的脚本,根据操作...
UCI 数据库是机器学习和数据挖掘领域广泛使用的资源库,它包含了大量的公开数据集,供研究者进行算法开发和模型验证。其中,“Sonar”数据集是一个专门用于分类问题的经典实例,尤其适用于模式识别和异常检测。这个...
### UCI数据库中的Iris数据集详解 #### 数据集简介 **Iris数据集**是机器学习领域中非常著名的一个数据集,常被用于数据挖掘、分类与聚类算法的教学和研究之中。此数据集由英国统计学家和生物学家Ronald Fisher在...
标题中的"Iris和sonar数据集"指的是两个广泛用于机器学习和数据分析的样例数据集。Iris数据集是统计学和数据科学领域最经典的数据集之一,由生物学家Ronald Fisher在1936年收集,包含了150个鸢尾花样本,每个样本有4...
1. **指定项目元数据**:例如 `sonar.projectKey`、`sonar.projectName` 和 `sonar.projectVersion`。 2. **定义源文件路径**:使用 `sources` 指定源代码所在的位置。 3. **定义测试文件路径**(可选):使用 `...
4. 修改`sonarqube-6.2/conf/sonar.properties` 文件,配置数据库连接(默认使用H2内嵌数据库,也可以配置为MySQL、PostgreSQL等)和其他必要设置。 5. 创建一个启动脚本,例如在 `/etc/init.d/sonarqube`,以便通过...
这个压缩包"sonar_fisher.zip"包含了与模式识别相关的资源,特别是使用Fisher线性判别分析(Fisher's Linear Discriminant Analysis, FDA)对Sonar数据进行分类的研究。 **Fisher线性判别分析(FDA)**: Fisher...
1. 在项目文件夹下建立 sonar-project.properties 文件:sonar-project.properties 文件用于配置项目的分析信息,例如项目的名称、版本号等。 2. 打开 cmd,输入 sonar-runner 命令开始扫描项目:Sonar-runner 命令...
sonar4版本扫描辅助程序. 向服务器上传代码并做扫描分析. 使用方式: CMD切换到项目根目录下(sonar-project.properties文件所在目录)运行 sonar-runner
在SonarRunner 2.4中,你可以通过配置文件(如`sonar-project.properties`)来定义你要分析的项目、使用的编码规则以及报告的格式。配置文件通常包含项目的唯一标识、源代码路径、语言类型、以及任何特定的分析参数...
数据库方面,虽然Apache Derby在Sonar 3.2之前的版本中被支持,但因升级限制,Sonar推荐使用企业级数据库。支持的数据库包括H2、Microsoft SQL Server 2005(需使用jTDS驱动)、MySQL 5.X和6.X、Oracle 10G和11G以及...
-- 其他配置属性,如sonar.projectKey, sonar.projectName, sonar.projectVersion等 --> </sonar:sonar> ``` 在这个例子中,我们首先通过引入了SonarAntTask,然后在<sonar:sonar>任务中配置了SonarQube服务器的...
2. **创建数据库用户**:在数据库管理系统中创建一个名为`SONAR`的用户,密码设置为`SONAR`,确保该用户有权限访问和操作SonarQube所需的表。 3. **配置数据库驱动**:将Oracle JDBC驱动jar包复制到SonarQube的`/...
默认情况下,SonarQube 使用内嵌的数据库,但可以通过修改 conf/sonar.properties 文件,将数据库改为 MySQL。例如,设置如下参数: ```properties sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=...