gpt4 book ai didi

java.lang.IllegalArgumentException : Cannot instantiate interface org. springframework.context.ApplicationContextInitializer

转载 作者:太空宇宙 更新时间:2023-11-04 10:46:33 25 4
gpt4 key购买 nike

我尝试在安装 Spring CLI 后运行快速启动 cli 示例。

https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started-installing-spring-boot.html#getting-started-cli-example

开启:$ spring run app.groovy

错误:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (jar:file:/home/dvraghu15/.install/spring-1.5.9.RELEASE/lib/spring-boot-cli-1.5.9.RELEASE.jar!/BOOT-INF/lib/groovy-2.4.13.jar!/) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at org.springframework.boot.cli.app.SpringApplicationLauncher.launch(SpringApplicationLauncher.java:65)
at org.springframework.boot.cli.command.run.SpringApplicationRunner$RunThread.run(SpringApplicationRunner.java:173)
Caused by: java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationContextInitializer : org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:413)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:392)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:383)
at org.springframework.boot.SpringApplication.initialize(SpringApplication.java:249)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:225)
... 6 more
Caused by: java.lang.NoClassDefFoundError: java/sql/SQLException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:409)
... 10 more
Caused by: java.lang.ClassNotFoundException: java.sql.SQLException
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader.findClass(ExtendedGroovyClassLoader.java:84)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563)
at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:677)
at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787)
at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:775)
... 12 more

请大家指导一下。

最佳答案

我不确定你是否可以尝试一下:

--add-modules=java.sql

我假设 spring.boot 是一个自动模块。自动模块不会声明它的依赖项,因此您必须使用 --add-modules 来确保解析所需的任何显式模块。如果 spring.boot 是一个显式模块,那么我假设它需要 java.sql 并且您不会遇到此问题。

here有同样的问题

关于java.lang.IllegalArgumentException : Cannot instantiate interface org. springframework.context.ApplicationContextInitializer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48354105/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com