You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Spring Boot 3原生镜像中启用HTTPS?

Spring Boot 3 开启GraalVM原生镜像HTTPS支持的替代方案

在Spring Boot 3/Spring 6中,原@NativeHint注解已被移除,你可以通过以下几种方式实现开启GraalVM镜像HTTPS支持的效果:

  • 通过构建插件配置原生镜像参数

    • Maven:在spring-boot-maven-plugin的native配置中添加--enable-https参数
      <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <configuration>
              <image>
                  <arguments>
                      <argument>--enable-https</argument>
                  </arguments>
              </image>
          </configuration>
      </plugin>
      
    • Gradle:在nativeBuild任务的arguments中添加该参数
      tasks.named('nativeBuild') {
          arguments.add('--enable-https')
      }
      
  • 使用GraalVM官方的@NativeImageHint注解
    引入GraalVM SVM依赖后,在应用主类上添加该注解:

    import org.graalvm.nativeimage.hosted.NativeImageHint;
    
    @NativeImageHint(options = "--enable-https")
    @SpringBootApplication
    public class YourApplication {
        public static void main(String[] args) {
            SpringApplication.run(YourApplication.class, args);
        }
    }
    
  • 通过native-image.properties文件配置
    在src/main/resources/META-INF目录下创建native-image.properties文件,添加以下内容:

    Args = --enable-https
    

内容的提问来源于stack exchange,提问作者edeandrea

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 15:45:03