当前位置: 首页 > 知识库问答 >
问题:

无法使用指定的Gradle installation for Spring Tool Suite创建工具API实现的实例

谭宜
2023-03-14

我已经从中创建了一个Spring Boot项目https://start.spring.io/使用gradle。

现在,当我尝试在Spring Tool Suite版本:3.9.6中导入项目时。释放,我得到的错误为

org.gradle.tooling.GradleConnectionException: Could not create an instance of Tooling API implementation using the specified Gradle installation '/usr/share/gradle'.
    at org.gradle.tooling.internal.consumer.loader.DefaultToolingImplementationLoader.create(DefaultToolingImplementationLoader.java:95)
    at org.gradle.tooling.internal.consumer.loader.CachingToolingImplementationLoader.create(CachingToolingImplementationLoader.java:44)
    at org.gradle.tooling.internal.consumer.loader.SynchronizedToolingImplementationLoader.create(SynchronizedToolingImplementationLoader.java:43)
    at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.onStartAction(LazyConsumerActionExecutor.java:101)
    at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:83)
    at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45)
    at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
    at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultModelBuilder.get(DefaultModelBuilder.java:50)
    at org.gradle.tooling.internal.consumer.DefaultProjectConnection.getModel(DefaultProjectConnection.java:41)
    at org.eclipse.buildship.core.internal.IdeAttachedProjectConnection.configureOperation(IdeAttachedProjectConnection.java:64)
    at org.eclipse.buildship.core.internal.IdeAttachedProjectConnection.model(IdeAttachedProjectConnection.java:55)
    at org.eclipse.buildship.core.internal.IdeAttachedProjectConnection.getModel(IdeAttachedProjectConnection.java:82)
    at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider$1.lambda$call$0(DefaultModelProvider.java:88)
    at org.eclipse.buildship.core.internal.DefaultGradleBuild$GradleConnectionOperation.runInToolingApi(DefaultGradleBuild.java:312)
    at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager$WorkspaceRunnableAdapter.run(DefaultToolingApiOperationManager.java:57)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2319)
    at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:38)
    at org.eclipse.buildship.core.internal.DefaultGradleBuild.withConnection(DefaultGradleBuild.java:112)
    at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider$1.call(DefaultModelProvider.java:88)
    at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:5065)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3716)
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2424)
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2298)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2211)
    at com.google.common.cache.LocalCache.get(LocalCache.java:4154)
    at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:5060)
    at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider.getFromCache(DefaultModelProvider.java:123)
    at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider.executeOperation(DefaultModelProvider.java:115)
    at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider.executeModelQuery(DefaultModelProvider.java:84)
    at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider.fetchModel(DefaultModelProvider.java:49)
    at org.eclipse.buildship.ui.internal.wizard.project.ProjectPreviewWizardPage.fetchBuildEnvironment(ProjectPreviewWizardPage.java:453)
    at org.eclipse.buildship.ui.internal.wizard.project.ProjectPreviewWizardPage.access$600(ProjectPreviewWizardPage.java:80)
    at org.eclipse.buildship.ui.internal.wizard.project.ProjectPreviewWizardPage$UpdatePreviewOperation.runInToolingApi(ProjectPreviewWizardPage.java:478)
    at org.eclipse.buildship.core.internal.operation.ToolingApiOperations$1.runInToolingApi(ToolingApiOperations.java:59)
    at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager$WorkspaceRunnableAdapter.run(DefaultToolingApiOperationManager.java:57)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2319)
    at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:38)
    at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:32)
    at org.eclipse.buildship.ui.internal.wizard.project.ProjectPreviewWizardPage$4.run(ProjectPreviewWizardPage.java:313)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: java.lang.RuntimeException: Could not create an implementation of service 'org.gradle.tooling.internal.protocol.ConnectionVersion4'.
    at org.gradle.internal.service.DefaultServiceLocator$ServiceFactory.newInstance(DefaultServiceLocator.java:182)
    at org.gradle.internal.service.DefaultServiceLocator$ServiceFactory.create(DefaultServiceLocator.java:175)
    at org.gradle.tooling.internal.consumer.loader.DefaultToolingImplementationLoader.create(DefaultToolingImplementationLoader.java:78)
    at org.gradle.tooling.internal.consumer.loader.CachingToolingImplementationLoader.create(CachingToolingImplementationLoader.java:44)
    at org.gradle.tooling.internal.consumer.loader.SynchronizedToolingImplementationLoader.create(SynchronizedToolingImplementationLoader.java:43)
    at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.onStartAction(LazyConsumerActionExecutor.java:101)
    at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:83)
    at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45)
    at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
    at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.gradle.api.reflect.ObjectInstantiationException: Could not create an instance of type org.gradle.tooling.internal.provider.DefaultConnection.
    at org.gradle.internal.reflect.DirectInstantiator.newInstance(DirectInstantiator.java:55)
    at org.gradle.internal.reflect.DirectInstantiator.instantiate(DirectInstantiator.java:35)
    at org.gradle.internal.service.DefaultServiceLocator$ServiceFactory.newInstance(DefaultServiceLocator.java:180)
    ... 16 more
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.gradle.tooling.internal.provider.DefaultConnection.<clinit>(DefaultConnection.java:73)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.gradle.internal.reflect.DirectInstantiator.newInstance(DirectInstantiator.java:51)
    ... 18 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 24 more

我使用的Gradle版本是

------------------------------------------------------------
Gradle 4.4.1
------------------------------------------------------------

Build time:   2012-12-21 00:00:00 UTC
Revision:     none

Groovy:       2.4.15
Ant:          Apache Ant(TM) version 1.10.5 compiled on August 27 2018
JVM:          11.0.1 (Oracle Corporation 11.0.1+13-Ubuntu-2ubuntu1)
OS:           Linux 4.18.0-13-generic amd64

我正在使用Buildship Gradle Integration 3.0 STS插件。是版本问题还是我做错了什么?

共有1个答案

封鸿雪
2023-03-14

我也犯了类似的错误:

org.gradle.tooling.GradleConnectionException: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-4.10.1-all.zip'.
...
Caused by: java.lang.ExceptionInInitializerError
...
Caused by: java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerAdapter cannot be cast to org.gradle.api.logging.Logger
...

我在我的整个系统中搜索了“slf4j”,并在 /usr/java/packages/lib/ext/.中找到了两个非常旧的. jar文件删除它们使我能够构建我的项目。

我怀疑您的问题是您必须添加slf4j jar文件,因为我有一个“ClassCastException”而您有一个“ClassNotFoundException”。

 类似资料:
  • 我正在尝试从GitHub导入一个项目,并在Android Studio上构建/运行它。我收到以下错误: “错误:无法使用指定的Gradle分发创建工具API实现的实例”https://services.gradle.org/distributions/gradle-2.4-all.zip'." 我尝试了以下方法: 使缓存无效并重新启动 将gradle包装/属性中的分发URL更改为2.5等 删除bu

  • 你好,我是android中MVVM的新手,正在使用livedata。我正在尝试创建viewmodel的一个实例。我觉得问题在于我没有将存储库传递给viewmodel构造函数。我一直无法创建viewmodel的实例。我不知道该怎么做这里是我的viewmodel和它的创建。

  • 我正在使用spring boot和Ignite数据库 我只创建了一个存储库,我正在Pojo中设置数据,以便使用IgniteRepository保存 下面是Ignite with Spring所需的依赖项:Ignite Version::2.0.0 这里我使用的是H2数据库依赖项,如果不使用它,我会收到另一个完全未知的错误。 点火配置: 用户POJO: 运行后,我得到错误:

  • 问题内容: com.amazonaws.services.ec2是否包含从现有AMI创建全新EC2实例的方法?我希望通过Java SDK而不是Web管理控制台来执行此操作。 问题答案: RunInstances是方法,它应该在SDK中。

  • 我正在开发一本新书android应用程序,但当我测试从logcat获取以下异常的代码时,应用程序崩溃 hread.mainRuntimeException:无法启动活动ComponentInfo{hread.java:6662}:java.lang.reflect.RuntimeException:无法创建ethod.invokeBookViewModel类的实例com.android.inter