连接mongodb时出现spring本机问题

scyqe7ek  于 2021-07-14  发布在  Java
关注(0)|答案(1)|浏览(455)

我的spring应用程序使用mongodb实现持久性。应用程序使用用户名/密码连接到mongodb。
为了找到springnative的好处,我在ubuntu18lts上创建了一个docker映像。当我使用docker compose运行app image和mongodb image时,一切看起来都很好。当我调用插入mongodb的restapi时,应用程序抛出一个错误

com.oracle.svm.core.jdk.UnsupportedFeatureError: Trying to verify a provider that was not registered at build time: SunJCE version 11. 
All providers must be registered and verified in the Native Image builder. 
Only the SUN provider is registered and verified by default. 
All other built-in providers are processed when all security services are enabled 
using the --enable-all-security-services option. 
Third party providers must be configured in the Native Image builder VM. 
at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87)
native-demo |   at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:384)
native-demo |   at javax.crypto.JceSecurity.canUseProvider(JceSecurity.java:231)
native-demo |   at javax.crypto.Mac.getInstance(Mac.java:186)
native-demo |   at com.mongodb.internal.connection.ScramShaAuthenticator$ScramShaSaslClient.hi(ScramShaAuthenticator.java:299)

操作系统:ubuntu 18 lts
spring原生版本:0.9.0
Spring Boot:2.4.3
指https://www.graalvm.org/reference-manual/native-image/buildconfiguration/#configuration-文件格式,我还创建了一个文件meta-inf/native-image.properties,包含以下内容 NativeImageArgs = --enable-all-security-services 即使重建了图像,问题仍然存在。
如何解决此问题?任何可能的解决方案的建议。

rvpgvaaj

rvpgvaaj1#

你能在你的springbootmaven插件上添加一个构建参数吗?

<configuration>
                    <image>
                        <builder>paketobuildpacks/builder:tiny</builder>
                        <env>
                            <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
                            <BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
                                - H:IncludeResourceBundles=sun.security.util.Resources
                            </BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
                        </env>
                    </image>
                </configuration>

相关问题