GraalVM + Springboot3 + IDEA completes the construction of localization services on widow10

GraalVM is a tool for developers to write and execute Java code. Specifically, GraalVM is the Java Virtual Machine (JVM) and Java Development Kit (JDK) created by Oracle. It is a high-performance runtime that improves application performance and efficiency.

The goals of GraalVM include: writing a faster and more maintainable compiler, improving the performance of languages ​​running on the JVM, reducing application startup time, integrating multilingual support into the Java ecosystem, and providing a set of Programming Tools.

GraalVM adds an optimizing compiler to the JDK, which provides performance optimizations for various languages ​​and interoperability for multilingual applications. In addition to supporting Java code, GraalVM also supports other programming languages, including Scala, Kotlin, Groovy, Clojure, R, Python, JavaScript, and Ruby. Essentially, GraalVM allows developers to efficiently run code in multiple languages ​​and libraries within a single application.
 

One, preparation work:

1. Install GraalVM 

   Download address: https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-22.3.0

unzip to local

2. Configure the GRAALVM_HOME environment variable

3. Path configuration

4. Verify the installation result:

 

 Indicates that the environment configuration is complete;

2. Install native image for building

1. Due to network problems, you need to manually download the corresponding version

 2. Local cmd, execute the command 

gu install -L native-image-installable-svm-java11-windows-amd64-22.0.0.2.jar

3. Verification; you can use the command to view the installed functions

gu list

 

 Successful installation;

Third, build a spring boot 3 project

 IDEA uses version 2022.3

 Pay attention to select the graalvm sdk just installed;

2. Configure the project pom file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.0</version>
    </parent>

    <groupId>你的组织名</groupId>
    <artifactId>你的项目名</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.graalvm.buildtools</groupId>
                <artifactId>native-maven-plugin</artifactId>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>build-native</id>
                        <goals>
                            <goal>compile-no-fork</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                    <execution>
                        <id>test-native</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>test</phase>
                    </execution>
                </executions>
                <configuration>
                    <!--此处是入口类,必须与实际代码一致,否则无法打包成功-->
                    <mainClass>com.fate.boot3.Boot3Application</mainClass>
                    <!-- 生成的exe文件名-->
                    <imageName>boot-test</imageName>
                    <buildArgs>
                        <buildArg>--verbose</buildArg>
                    </buildArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

3. Do not configure other things first, write a simple test method in the same way as springboot 2;

4. start

Guess you like

Origin blog.csdn.net/zy_jun/article/details/128201860