maven-native打包springboot项目(idea里)
需要GraalVM
mvn -Pnative native:compile
idea设置打包
java使用你下载的GraalVM的java
这个是环境变量没配置好
命令行maven打包
<build> <!--包名--> <!-- <finalName>${project.artifactId}</finalName>--> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring-boot.version}</version> <!--替换为你的应用程序主类--> <configuration> <mainClass>com.cabin.CabinApplication</mainClass> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> <executions> <execution> <id>repackage</id> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
mvn -Pnative-image package
org.graalvm.nativeimage--native-image-maven-plugin
<properties> <main-class>com.example.GraalvmSpringBootDemoApplication</main-class> </properties> <build> <plugins> <plugin> <groupId>org.graalvm.nativeimage</groupId> <artifactId>native-image-maven-plugin</artifactId> <version>21.0.0.2</version> <configuration> <skip>false</skip> <imageName>${project.artifactId}</imageName> <buildArgs> --no-fallback </buildArgs> </configuration> <executions> <execution> <goals> <goal>native-image</goal> </goals> <phase>package</phase> </execution> </executions> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>3.1.0</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>${main-class}</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
mvn clean package -Pnative