java - Spring 应用程序上的 NoClassDefFoundError

标签 java spring ubuntu noclassdeffounderror

此图像中存在完整错误,因为我在云中的虚拟机上运行,​​该虚拟机可通过视频源访问,因此我无法复制和粘贴。这是全新安装的 ubuntu,其中我只安装了 JDK,没有其他任何东西,因此不知道是否需要完成其他设置 /image/LmuH1.jpg

这是一个 Spring Boot 应用程序。 我的 build.gradle

group 'com.haughon.daniel'
version '1.0-SNAPSHOT'



buildscript {
repositories{
    mavenCentral()
}
dependencies {
    classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE'
}
}

// Apply the Spring Boot plugin
apply plugin: 'spring-boot'

 // Apply the Java plugin (expects src/main/java to be source folder)
 apply plugin: 'java'
apply plugin: 'idea'

 // Specify the location where our dependencies will be found
repositories {
mavenCentral()
}
jar {
   manifest {
    attributes 'Main-Class': 'haughton.dvdstore.Application'
    attributes 'addClasspath': 'true'

}
}

 // Specify dependencies
  dependencies {

compile 'org.hashids:hashids:1.0.1'
compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
compile 'org.springframework:spring-orm:4.3.7.RELEASE'
compile 'org.hibernate:hibernate-core:5.2.9.Final'
compile 'org.hibernate:hibernate-entitymanager:5.0.6.Final'
compile 'org.apache.tomcat:tomcat-dbcp:8.0.30'
compile 'org.springframework.boot:spring-boot-starter-security'
compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4')
//compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity:3.0.2.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.11.1.RELEASE'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.8'

runtime 'com.h2database:h2'
runtime 'javax.transaction:jta:1.1'
runtime 'org.aspectj:aspectjweaver:1.8.7'
testCompile 'org.springframework.boot:spring-boot-starter-test'
}  

最佳答案

这是因为您的依赖项未包含在一个 jar 文件中。

使用./gradlew clean build

请参阅这篇文章:

java.lang.NoClassDefFoundError: when trying to run jar

关于java - Spring 应用程序上的 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46748902/

相关文章:

ubuntu - 允许用户通过 ssh 连接到 EC2 Ubuntu 实例?

java - Google App Engine 中的自有关系不起作用

java - 本地依赖的 Gradle 依赖

java - 没有找到类型匹配的 bean ... 来进行依赖...预计至少有 1 个有资格作为 Autowiring 候选者的 bean

json - 无法写入 JSON : Infinite recursion (StackOverflowError); nested exception spring boot

java - 如何使用 Spring Data 从 Spring Boot 中的实体中选择几个字段?

ubuntu - ImageMagick比较:从PSNR结果中忽略白色匹配

ubuntu - 终止容器后无法删除 Docker 的镜像

java - map 对象上的 NullPointerException

java - java eclipse中的断点错误