fanrendale 2019-03-20 14:37 采纳率: 0%
浏览 748

Jenkins部署springboot,打包好了之后报Could not initialize class sun.nio.fs.LinuxNativeDispatcher

图片说明
请问这是为什么啊?

  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-08-08 10:27
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    这个问题是由于Spring Boot项目在构建过程中遇到的问题。Sun Native FileSystem Provider是Java的文件系统API的一部分,在Jenkins中,我们可以通过以下步骤解决这个问题:

    1. 首先,我们需要确保已经安装了Apache Ant和Apache Maven。

    2. 在项目的pom.xml文件中添加以下依赖:

    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ant-plugin</artifactId>
        <version>3.0.0-M3</version>
    </dependency>
    
    <dependency>
        <groupId>com.github.johnrengelman</groupId>
        <artifactId>ant-maven-plugin</artifactId>
        <version>3.2.0</version>
    </dependency>
    
    1. 在项目的build.gradle文件中添加以下依赖:
    dependencies {
        implementation 'org.apache.maven.plugins:maven-ant-plugin:3.0.0-M3'
        implementation 'com.github.johnrengelman:ant-maven-plugin:3.2.0'
    }
    
    1. 然后,在src/main/resources/META-INF/maven/org.example/example/pom.properties文件中添加以下配置:
    sun.io.native.NativeCompiler=org.apache.maven.plugins:maven-ant-plugin:3.0.0-M3
    sun.io.native.NativeCompiler=org.apache.maven.plugins:maven-ant-plugin:3.0.0-M3
    
    1. 最后,在你的Spring Boot项目中创建一个名为build.gradle.kts的文件,并添加以下内容:
    plugins {
        kotlin("jvm") version "1.3.71"
    }
    
    group = "com.example"
    version = "0.0.1-SNAPSHOT"
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation(kotlin("stdlib-jdk8"))
    }
    
    tasks.withType<KotlinCompile> {
        kotlinOptions.jvmTarget = "1.8"
    }
    

    现在,你应该可以在Spring Boot项目中使用maven-ant-plugin来编译和打包你的项目。如果你仍然遇到问题,请检查你的环境变量是否正确设置,或者查看Apache Ant或Apache Maven的文档以获取更多帮助。

    评论

报告相同问题?