my project config:
spring-boot 3.1.1; maven3.8
pom.xml:
...
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<buildArgs combine.children="append">
<!-- fix: UnsupportedEncodingException: GB2312 -->
<!--<arg>-H:+AddAllCharsets</arg>--><!-- not work -->
<buildArg>-H:+AddAllCharsets</buildArg>
</buildArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
build:
mvn spring-boot:build-image -Pnative
run:
docker run --rm -p 9876:9876 user-server:1.0-SNAPSHOT
ERROR 1 --- [nio-9876-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.IllegalArgumentException: Please check the content of the SMS, gb2312 encoding cannot be completed] with root cause
java.io.UnsupportedEncodingException: gb2312
at java.base@17.0.7/java.net.URLEncoder.encode(URLEncoder.java:198)
at com.newhope.security.adapter.sms.Content.gb2312Encode(Content.java:30)
at com.newhope.security.adapter.sms.Content.gb2312Message(Content.java:21)
at com.newhope.security.adapter.sms.SmsTemplate.lambda$sending$0(SmsTemplate.java:48)
Comment From: wilkinsona
You are using buildpacks to create the native image of your application but have configured -H:+AddAllCharsets on the native image Maven plugin which isn't used. You need to configure BP_NATIVE_IMAGE_BUILD_ARGUMENTS on Spring Boot's plugin instead similar to this example in the documentation.
If you have any further questions, please follow up on Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.