sonarqube代碼分析平台踩坑指南


環境描述

系統:win10
版本:sonarqube8.8.0.4
啟動StartSonar.bat出現如下錯誤

錯誤信息1

--> Wrapper Started as Console
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.


WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: SonarQube requires Java 11 to run
java.lang.IllegalStateException: SonarQube requires Java 11 to run
	at com.google.common.base.Preconditions.checkState(Preconditions.java:508)
	at org.sonar.application.App.checkJavaVersion(App.java:93)
	at org.sonar.application.App.start(App.java:56)
	at org.sonar.application.App.main(App.java:97)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
	at java.lang.Thread.run(Thread.java:748)
<-- Wrapper Stopped

原因分析

需要安裝java11版本才能運行,而我只安裝了java8

錯誤信息2

Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2021.04.27 12:36:21 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory D:\sonarqube-8.8.0.42792\temp
2021.04.27 12:36:21 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:59370]
2021.04.27 12:36:21 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [D:\sonarqube-8.8.0.42792\elasticsearch]: C:\Program Files\Java\jdk-16.0.1\bin\java -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Djava.io.tmpdir=D:\sonarqube-8.8.0.42792\temp -XX:ErrorFile=../logs/es_hs_err_pid%p.log -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.locale.providers=COMPAT -Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.path.home=D:\sonarqube-8.8.0.42792\elasticsearch -Des.path.conf=D:\sonarqube-8.8.0.42792\temp\conf\es -cp lib/* org.elasticsearch.bootstrap.Elasticsearch
Unrecognized VM option 'UseConcMarkSweepGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
2021.04.27 12:36:21 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1
2021.04.27 12:36:21 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2021.04.27 12:36:21 INFO  app[][o.s.a.SchedulerImpl] Process[es] is stopped
2021.04.27 12:36:21 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped
--> Wrapper Started as Console

原因分析

SonarQube掃描程序需要JVM的版本8或11,而SonarQube服務器需要的版本11。官方不支持Java 11以外的版本。我這里安裝最新版本16導致此問題

解決辦法

安裝java11版本,記得配置環境變量哦

問題完美解決,腦抽自以為是向上兼容的

訪問127.0.0.1:9000 登陸用戶:admin 密碼:admin


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM