Spring Boot教程,运行简单应用程序时出错

问题描述 投票:0回答:1

根据本教程https://www.tutorialspoint.com/spring_boot/spring_boot_quick_start.htm,我正在尝试如下执行一个简单的Groovy文件:

@Controller
class Example {
   @RequestMapping("/")
   @ResponseBody
   public String hello() {
      "Hello Spring Boot"
   }
}

但是我看到以下错误:

startup failed:
General error during conversion: org.eclipse.aether.resolution.DependencyResolutionException: Failed to collect dependencies at org.springframework.boot:spring-boot-starter:jar:2.3.0.BUILD-SNAPSHOT

org.springframework.boot.cli.compiler.grape.DependencyResolutionFailedException: org.eclipse.aether.resolution.DependencyResolutionException: Failed to collect dependencies at org.springframework.boot:spring-boot-starter:jar:2.3.0.BUILD-SNAPSHOT
        at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.resolve(AetherGrapeEngine.java:298)
        at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.grab(AetherGrapeEngine.java:116)
        at groovy.grape.Grape.grab(Grape.java:166)
        at groovy.grape.GrabAnnotationTransformation.visit(GrabAnnotationTransformation.java:376)
        at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:319)
        at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:954)
        at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:636)
        at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:612)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:589)
        at org.springframework.boot.cli.compiler.GroovyCompiler.compile(GroovyCompiler.java:197)
        at org.springframework.boot.cli.command.run.SpringApplicationRunner.compile(SpringApplicationRunner.java:125)
        at org.springframework.boot.cli.command.run.SpringApplicationRunner.compileAndRun(SpringApplicationRunner.java:97)
        at org.springframework.boot.cli.command.run.RunCommand$RunOptionHandler.run(RunCommand.java:111)
        at org.springframework.boot.cli.command.options.OptionHandler.run(OptionHandler.java:85)
        at org.springframework.boot.cli.command.OptionParsingCommand.run(OptionParsingCommand.java:54)
        at org.springframework.boot.cli.command.CommandRunner.run(CommandRunner.java:219)
        at org.springframework.boot.cli.command.CommandRunner.runAndHandleErrors(CommandRunner.java:171)
        at org.springframework.boot.cli.SpringCli.main(SpringCli.java:64)
        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.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Failed to collect dependencies at org.springframework.boot:spring-boot-starter:jar:2.3.0.BUILD-SNAPSHOT
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:351)
        at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.resolve(AetherGrapeEngine.java:293)
        ... 25 more
Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect dependencies at org.springframework.boot:spring-boot-starter:jar:2.3.0.BUILD-SNAPSHOT
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:293)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:307)
        ... 26 more
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.springframework.boot:spring-boot-starter:jar:2.3.0.BUILD-SNAPSHOT
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:276)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:192)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:539)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:522)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:411)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:365)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:353)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:256)
        ... 27 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.springframework.boot:spring-boot-starter:pom:2.3.0.BUILD-SNAPSHOT from/to spring-snapshot (https://repo.spring.io/snapshot): proxy.host
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:422)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:224)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:201)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:261)
        ... 34 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.springframework.boot:spring-boot-starter:pom:2.3.0.BUILD-SNAPSHOT from/to spring-snapshot (https://repo.spring.io/snapshot): proxy.host
        at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:52)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:365)
        at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:583)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:259)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:498)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:399)
        ... 37 more
Caused by: java.net.UnknownHostException: proxy.host
        at java.net.InetAddress.getAllByName0(InetAddress.java:1281)
        at java.net.InetAddress.getAllByName(InetAddress.java:1193)
        at java.net.InetAddress.getAllByName(InetAddress.java:1127)
        at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:263)
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
        at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:326)
        at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:605)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:440)
        at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
        at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:164)
        at org.eclipse.aether.transport.http.HttpTransporter.execute(HttpTransporter.java:296)
        at org.eclipse.aether.transport.http.HttpTransporter.implGet(HttpTransporter.java:252)
        at org.eclipse.aether.spi.connector.transport.AbstractTransporter.get(AbstractTransporter.java:67)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:453)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:360)
        ... 42 more

1 error

我已经被Google搜索过,发现了这个古老的讨论,但是对我没有帮助。

spring-boot groovy
1个回答
1
投票

似乎您的代理配置有问题,并且Java无法下载依赖项。它无法解析proxy.host变量。

您必须已经为Java实例设置了代理配置。尝试解决此配置问题,它应该可以工作。

如果使用的是Spring Build Snapshot,请记住配置快照存储库。有关更多信息,请参见https://www.baeldung.com/spring-maven-repository

热门问题
推荐问题
最新问题