Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot native enable https during build

I am getting the below error when I tried to use HTTPS in spring native application.

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 protocol was not enabled. Please help me to enable during the build.

Update

Found the solution, looking on spring native documentation. https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#native-image-options

Add the below code to pom.xml under the plugin section

<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-https</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>

Updated pom.xml looks like this.

<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>
like image 821
zeeshan ansari Avatar asked Oct 18 '25 02:10

zeeshan ansari


1 Answers

or if you using graalvm native image plugin:

                     <plugin>
                        <groupId>org.graalvm.nativeimage</groupId>
                        <artifactId>native-image-maven-plugin</artifactId>
                        <version>21.0.0</version>
                        <configuration>
                            <!-- The native image build needs to know the entry point to your application -->
                            <mainClass>com.dccorp.nativeapps.NativeCloudStreamsApplication</mainClass>
                            <buildArgs>
                                <!-- uncomment to generate dump file for graalvm dashboard analysis.-->
                                <!-- -H:DashboardDump=dumpfileoversizedbuildArgs-->
                                <!-- -H:+DashboardAll-->
                                <!-- you can provide additional params. -->
                                <!-- -H:DynamicProxyConfigurationFiles=classes/proxy-config.json-->
                                <!-- -H:ReflectionConfigurationFiles=classes/reflect-config.json-->
                                --enable-url-protocols=http
                            </buildArgs>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>native-image</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
like image 82
Deepak Chaudhary Avatar answered Oct 19 '25 16:10

Deepak Chaudhary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!