当我尝试在 Spring 本机应用程序中使用 HTTPS 时出现以下错误。
java.net.MalformedURLException: Accessing an URL protocol that was not enabled. The URL protocol HTTPS is supported but not enabled by default. It must be enabled by adding the --enable-url-protocols=https option to the native-image command.
HTTPS URL 协议未启用。请帮助我在构建期间启用。
更新
找到解决方案,查看 spring 本机文档。 https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#native-image-options
将以下代码添加到插件部分下的 pom.xml
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-https</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
更新后的 pom.xml 看起来像这样。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder:tiny</builder>
<env>
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-https</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
</env>
</image>
</configuration>
</plugin>