当前位置:   article > 正文

【已解决】【一眼就会】Exception in thread “main“ java.lang.NoClassDefFoundError java.lang.ClassNo【jar中没有主清单属性】_exception in thread "main" java.lang.noclassdeffou

exception in thread "main" java.lang.noclassdeffounderror: com/alibaba/fastj

《一眼就会系列》每天抽出一点时间巩固基础!同时学习最新知识(与时俱进)!罗列、简述、概括问题,让读者扫一眼就知道该如何处理。

其实就是配置文件和包的版本问题。

解决方法如下:(请放大并用超清观看)

java

 

build.gradle 配置文件:

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'idea'
version '1.0-SNAPSHOT'
repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
    //jdbc
    compile 'org.springframework.boot:spring-boot-starter-jdbc:2.5.3'
    compile 'mysql:mysql-connector-java:8.0.28'
    //json
    compile 'com.alibaba:fastjson:1.2.39'
    //spring
    compile 'org.springframework.boot:spring-boot-starter-web:2.5.2'
    /* log4j */
    compile 'org.apache.logging.log4j:log4j-core:2.17.1'
    compile 'org.apache.logging.log4j:log4j-api:2.17.1'
    //swagger:
    compile 'io.springfox:springfox-swagger2:3.0.0'
    compile 'io.springfox:springfox-swagger-ui:3.0.0'
    compile 'com.google.guava:guava:31.0.1-jre'
    compile 'junit:junit:4.12'
}

jar {
    String JarPathAll = ''
    configurations.runtime.each {JarPathAll = JarPathAll + " lib\\"+it.name}
    manifest {
        attributes 'Main-Class': 'org.example.ApplicationStart'
        attributes 'Class-Path': JarPathAll
    }
}

test {
    useJUnitPlatform()
}

ApplicationStart.java 启动文件:

package org.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class ApplicationStart {
    public static void main(String[] args) {
        SpringApplication.run(ApplicationStart.class);
    }
}
 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/278842?site
推荐阅读
相关标签
  

闽ICP备14008679号