DEV Community

davino
davino

Posted on • Edited on

Java native hack

Configure Profile

Add the following to the submodule:

<profiles>
  <profile>
    <id>native</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <build>
      <plugins>
        <plugin>
          <groupId>org.graalvm.buildtools</groupId>
          <artifactId>native-maven-plugin</artifactId>
          <configuration>
            <mainClass>
              com.github.crazyrunsnail.careportal.module.hospital.CarePortalHospitalApplication
            </mainClass>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>
Enter fullscreen mode Exit fullscreen mode

Configure spring-boot-maven-plugin

Add the following under spring-boot-maven-plugin:

<executions>
  <execution>
    <id>process-aot</id>
    <goals>
      <goal>process-aot</goal>
    </goals>
  </execution>
</executions>
<configuration>
  <mainClass>com.github.crazyrunsnail.careportal.module.hospital.CarePortalHospitalApplication</mainClass>
  <excludes>
    <exclude>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
    </exclude>
  </excludes>
</configuration>
Enter fullscreen mode Exit fullscreen mode

Remove spring-boot-devtools Dependency

<!--        <dependency>-->
<!--            <groupId>org.springframework.boot</groupId>-->
<!--            <artifactId>spring-boot-devtools</artifactId>-->
<!--            <scope>runtime</scope>-->
<!--            <optional>true</optional>-->
<!--        </dependency>-->
Enter fullscreen mode Exit fullscreen mode

Run:

mvn -Pnative clean native:compile
Enter fullscreen mode Exit fullscreen mode




Configure MyBatis and MyBatis Plus

Add configuration classes: MybatisPlusRuntimeHintsRegistrar and
MyBatisNativeConfiguration.

Run again:

mvn -Pnative clean native:compile
Enter fullscreen mode Exit fullscreen mode




References

Top comments (0)