【发布时间】:2021-03-20 05:09:10
【问题描述】:
当我尝试在 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>
【问题讨论】:
-
请不要在问题中回答你的问题。而是在实际答案中回答它,并在几天后接受它,如果它仍然是最佳答案。这样其他人更容易找到答案,并且可以很容易地看到问题已得到解答。你也可能会得到答案。
标签: java spring spring-boot graalvm spring-native