首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Spring Boot开发人员工具时,IntelliJ无法启动Spring Boot/Gradle应用程序

使用Spring Boot开发人员工具时,IntelliJ无法启动Spring Boot/Gradle应用程序
EN

Stack Overflow用户
提问于 2017-07-10 23:53:48
回答 1查看 1.1K关注 0票数 2

我有一个Spring Boot应用程序,它无法在Gradle 2017.1.5中启动,只要我将Spring Boot developer tools添加到IntelliJ版本中,如下所示:

代码语言:javascript
复制
dependencies {
  compile("org.springframework.boot:spring-boot-starter-web")
  compile("org.apache.httpcomponents:httpclient:4.5.3")
  compile("com.fasterxml.jackson.core:jackson-databind:2.8.8.1")
  compile("commons-validator:commons-validator:1.6")

  // This line breaks IntelliJ compatibility:
  optional("org.springframework.boot:spring-boot-devtools")

  optional("org.springframework.boot:spring-boot-configuration-processor")
  testCompile("org.springframework.boot:spring-boot-starter-test")
  testCompile("junit:junit:4.12")
}

没有spring-boot-devtools,只要我添加了它们,启动应用程序(在IntelliJ中刷新Gradle项目之后)就会失败,并显示一个NoClassDefFoundError

代码语言:javascript
复制
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/web/client/RestTemplateBuilder
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.web.client.RestTemplateBuilder
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

我非常确定这是一个IntelliJ问题,因为在启用了Spring Boot developer tools的情况下,相同的应用程序在Eclipse中运行得很好。

有什么办法解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-31 23:46:18

我能够解决这个问题,方法是将spring-boot-devtools的依赖项改为:

代码语言:javascript
复制
runtime("org.springframework.boot:spring-boot-devtools")

而不是

代码语言:javascript
复制
optional("org.springframework.boot:spring-boot-devtools")
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45016574

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档