AnnotatedElementUtils.findMergedAnnotation

关于MongoDB,有一个核心操作类:MongoTemplate,使用这个MongoDB模板类可以很方便的对MongoDB数据进行CRUD操作,而这个类位于spring-data-mongodb这个jar包下,所以在使用maven进行web开发时,我们需要在pom.xml下引入依赖。

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-mongodb</artifactId>
    <version>2.0.8.RELEASE</version>
</dependency>
	
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongo-java-driver</artifactId>
    <version>3.8.0</version>
</dependency>

在操作过程中,老是出现如下错误:

java.lang.NoSuchMethodError:org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation(Ljava/lang/reflect/AnnotatedElement;Ljava/lang/Class;)

起初,以为是MongoDB的配置出了问题,但是经过调试,发现mongo-config.xml文件是没有问题的。

由于项目使用了spring框架,所以pom.xml文件引入了很多依赖,初步判断是依赖版本冲突导致,但是却无从下手。

经过度娘,了解到了spring-context (<spring.version>4.1.6.RELEASE</spring.version>)中会有spring-expression的版本信息

但是,在spring-data-mongodb 2.0.8.RELEASE的版本中也存在了spring-expression的版本信息,于是乎,这两者便产生了冲突

找到了问题所在,接下来便是解决问题了。

方法一:把    <artifactId>spring-data-mongodb</artifactId>
                      <version>2.0.8.RELEASE</version>
              换成 <artifactId>spring-data-mongodb</artifactId>
                        <version>1.4.2.RELEASE</version>
             也即是把 spring-data-mongodb 换成较低的 1.4.2.RELEASE 版本

方法二:  有网友说,在 spring-data-mongodb 依赖中去除 spring-expression 的版本信息,但是,此种方法在spring-data-mongodb的版本为2.0.8.RELEASE还是会不能解决问题,我在想,是不是2.0.8版本太高,其中不止spring-expression存在冲突,还有其它的spring包冲突

至此,使用第一种方法,解决折腾了一个上午的版本信息冲突问题,所以说程序猿的时间都去哪里了呢!!

另外,虽然说spring等一些主流框架会给我们带来开发上极大的便利了,但是有一些极细节的坑却是很多人都会不经意就会猜到,就像是上面的版本信息问题,相信很多人都遇到过

 

. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.7.18) 2025-06-20 16:28:46.079 INFO 25272 --- [ restartedMain] com.zdww.tpgg.auth.AuthApplication : Starting AuthApplication using Java 1.8.0_361 on Bone with PID 25272 (D:\idea-workplace\hnszxc-service\tpgg-auth\target\classes started by jyouj in D:\idea-workplace\hnszxc-service) 2025-06-20 16:28:46.080 INFO 25272 --- [ restartedMain] com.zdww.tpgg.auth.AuthApplication : The following 1 profile is active: "dev" 2025-06-20 16:28:46.120 INFO 25272 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable 2025-06-20 16:28:46.121 INFO 25272 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' 2025-06-20 16:28:47.377 INFO 25272 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode 2025-06-20 16:28:47.379 INFO 25272 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode. 2025-06-20 16:28:47.399 INFO 25272 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 5 ms. Found 0 Redis repository interfaces. 2025-06-20 16:28:47.512 WARN 25272 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.zdww.tpgg.auth]' package. Please check your configuration. 2025-06-20 16:28:47.628 INFO 25272 --- [ restartedMain] ptablePropertiesBeanFactoryPostProcessor : Post-processing PropertySource instances 2025-06-20 16:28:47.656 INFO 25272 --- [ restartedMain] c.u.j.EncryptablePropertySourceConverter : Converting PropertySource configurationProperties [org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource] to AOP Proxy 2025-06-20 16:28:47.657 INFO 25272 --- [ restartedMain] c.u.j.EncryptablePropertySourceConverter : Converting PropertySource servletConfigInitParams [org.springframework.core.env.PropertySource$StubPropertySource] to EncryptablePropertySourceWrapper 2025-06-20 16:28:47.657 INFO 25272 --- [ restartedMain] c.u.j.EncryptablePropertySourceConverter : Converting PropertySource servletContextInitParams [org.springframework.core.env.PropertySource$StubPropertySource] to EncryptablePropertySourceWrapper 2025-06-20 16:28:47.657 INFO 25272 --- [ restartedMain] c.u.j.EncryptablePropertySourceConverter : Converting PropertySource systemProperties [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper 2025-06-20 16:28:47.657 INFO 25272 --- [ restartedMain] c.u.j.EncryptablePropertySourceConverter : Converting PropertySource systemEnvironment [org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor$OriginAwareSystemEnvironmentPropertySource] to EncryptableMapPropertySourceWrapper 2025-06-20 16:28:47.657 INFO 25272 --- [ restartedMain] c.u.j.EncryptablePropertySourceConverter : Converting PropertySource random [org.springframework.boot.env.RandomValuePropertySource] to EncryptablePropertySourceWrapper 2025-06-20 16:28:47.657 INFO 25272 --- [ restartedMain] c.u.j.EncryptablePropertySourceConverter : Converting PropertySource Config resource 'class path resource [application-dev.yml]' via location 'optional:classpath:/' [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper 2025-06-20 16:28:47.657 INFO 25272 --- [ restartedMain] c.u.j.EncryptablePropertySourceConverter : Converting PropertySource Config resource 'class path resource [application.yml]' via location 'optional:classpath:/' [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper 2025-06-20 16:28:47.657 INFO 25272 --- [ restartedMain] c.u.j.EncryptablePropertySourceConverter : Converting PropertySource devtools [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper 2025-06-20 16:28:47.670 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'shiroConfig' of type [com.gsww.jzfp.security.common.shiro.config.ShiroConfig$$EnhancerBySpringCGLIB$$db63f5bd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:47.686 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'shiroSessionConfiguration' of type [com.gsww.jzfp.security.common.shiro.config.ShiroSessionConfiguration$$EnhancerBySpringCGLIB$$6f9ccbbb] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:47.693 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'defaultSessionManager' of type [org.apache.shiro.web.session.mgt.DefaultWebSessionManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:47.708 INFO 25272 --- [ restartedMain] c.u.j.r.DefaultLazyPropertyResolver : Property Resolver custom Bean not found with name 'encryptablePropertyResolver'. Initializing Default Property Resolver 2025-06-20 16:28:47.709 INFO 25272 --- [ restartedMain] c.u.j.d.DefaultLazyPropertyDetector : Property Detector custom Bean not found with name 'encryptablePropertyDetector'. Initializing Default Property Detector 2025-06-20 16:28:47.712 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jdpSecurityProperties' of type [com.gsww.jzfp.security.common.shiro.config.JdpSecurityProperties$$EnhancerBySpringCGLIB$$d7740153] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:47.729 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'authServerLoginRealm' of type [com.gsww.jzfp.security.common.shiro.loginAuth.AuthServerLoginRealm] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:47.746 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'authServerTokenRealm' of type [com.gsww.jzfp.security.common.shiro.tokenAuth.AuthServerTokenRealm] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:47.746 INFO 25272 --- [ restartedMain] c.g.j.s.common.shiro.config.ShiroConfig : -------shiro securityManager 初始化 shiroCacheType=redis 2025-06-20 16:28:48.430 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'rememberMeCookie' of type [org.apache.shiro.web.servlet.SimpleCookie] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.432 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'rememberMeManager' of type [org.apache.shiro.web.mgt.CookieRememberMeManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.433 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'securityManager' of type [org.apache.shiro.web.mgt.DefaultWebSecurityManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.437 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'redisConfiguration' of type [com.zdww.tpgg.auth.config.RedisConfiguration$$EnhancerBySpringCGLIB$$bf92ec21] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.443 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties' of type [org.springframework.boot.autoconfigure.data.redis.RedisProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.446 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration' of type [org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.457 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.actuate.autoconfigure.metrics.redis.LettuceMetricsAutoConfiguration' of type [org.springframework.boot.actuate.autoconfigure.metrics.redis.LettuceMetricsAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.457 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration' of type [org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.458 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'management.metrics.export.simple-org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleProperties' of type [org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.462 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'simpleConfig' of type [org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimplePropertiesConfigAdapter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.462 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration' of type [org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.463 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'micrometerClock' of type [io.micrometer.core.instrument.Clock$1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.477 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'simpleMeterRegistry' of type [io.micrometer.core.instrument.simple.SimpleMeterRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.479 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'micrometerOptions' of type [io.lettuce.core.metrics.MicrometerOptions] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.480 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'lettuceMetrics' of type [org.springframework.boot.actuate.autoconfigure.metrics.redis.LettuceMetricsAutoConfiguration$$Lambda$450/1519720651] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.541 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'lettuceClientResources' of type [io.lettuce.core.resource.DefaultClientResources] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.627 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'redisConnectionFactory' of type [org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.646 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'cacheManager' of type [org.springframework.data.redis.cache.RedisCacheManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.647 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'loginFailLimitService' of type [com.gsww.jzfp.security.server.modules.sys.service.LoginFailLimitService] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.649 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'com.gsww.jdp.boot.encrypt.JdpEncryptAutoConfiguration' of type [com.gsww.jdp.boot.encrypt.JdpEncryptAutoConfiguration$$EnhancerBySpringCGLIB$$dd4e14e5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.653 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jdp.encrypt-com.gsww.jdp.boot.encrypt.properties.EncryptProperties' of type [com.gsww.jdp.boot.encrypt.properties.EncryptProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.656 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'encryptHandle' of type [com.gsww.jdp.core.crypto.aes.AesEncryptHandleImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.657 INFO 25272 --- [ restartedMain] c.g.j.s.common.shiro.config.ShiroConfig : -------shiro ShiroFilterFactoryBean 初始化 2025-06-20 16:28:48.665 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'fixedSecretKeyProvider' of type [com.gsww.jdp.boot.encrypt.core.FixedSecretKeyProvider] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.668 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'secretKeyStore' of type [com.gsww.jdp.boot.encrypt.core.SecretKeyStoreDefaultImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.669 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'headerSecretKeyProvider' of type [com.gsww.jdp.boot.encrypt.core.HeaderSecretKeyProvider] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:48.670 INFO 25272 --- [ restartedMain] c.g.j.s.c.s.t.AuthServerTokenFilter : 注意:重写AuthServerTokenFilter,依赖jzfp-security:1.2.5 2025-06-20 16:28:48.699 INFO 25272 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'authorizationAttributeSourceAdvisor' of type [org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-06-20 16:28:49.076 INFO 25272 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9300 (http) 2025-06-20 16:28:49.083 INFO 25272 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2025-06-20 16:28:49.083 INFO 25272 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.83] 2025-06-20 16:28:49.171 INFO 25272 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2025-06-20 16:28:49.171 INFO 25272 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3050 ms 2025-06-20 16:28:49.522 INFO 25272 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 2025-06-20 16:28:49.606 INFO 25272 --- [ restartedMain] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource 2025-06-20 16:28:49.635 INFO 25272 --- [ restartedMain] c.u.j.encryptor.DefaultLazyEncryptor : String Encryptor custom Bean not found with name 'jasyptStringEncryptor'. Initializing Default String Encryptor 2025-06-20 16:28:49.637 INFO 25272 --- [ restartedMain] c.u.j.encryptor.DefaultLazyEncryptor : Encryptor config not found for property jasypt.encryptor.algorithm, using default value: PBEWithMD5AndDES 2025-06-20 16:28:49.637 INFO 25272 --- [ restartedMain] c.u.j.encryptor.DefaultLazyEncryptor : Encryptor config not found for property jasypt.encryptor.keyObtentionIterations, using default value: 1000 2025-06-20 16:28:49.637 INFO 25272 --- [ restartedMain] c.u.j.encryptor.DefaultLazyEncryptor : Encryptor config not found for property jasypt.encryptor.poolSize, using default value: 1 2025-06-20 16:28:49.637 INFO 25272 --- [ restartedMain] c.u.j.encryptor.DefaultLazyEncryptor : Encryptor config not found for property jasypt.encryptor.providerName, using default value: null 2025-06-20 16:28:49.637 INFO 25272 --- [ restartedMain] c.u.j.encryptor.DefaultLazyEncryptor : Encryptor config not found for property jasypt.encryptor.providerClassName, using default value: null 2025-06-20 16:28:49.637 INFO 25272 --- [ restartedMain] c.u.j.encryptor.DefaultLazyEncryptor : Encryptor config not found for property jasypt.encryptor.saltGeneratorClassname, using default value: org.jasypt.salt.RandomSaltGenerator 2025-06-20 16:28:49.637 INFO 25272 --- [ restartedMain] c.u.j.encryptor.DefaultLazyEncryptor : Encryptor config not found for property jasypt.encryptor.stringOutputType, using default value: base64 2025-06-20 16:28:49.692 WARN 25272 --- [ restartedMain] c.a.druid.pool.DruidAbstractDataSource : oracle.jdbc.driver.OracleDriver is deprecated.Having use oracle.jdbc.OracleDriver. 2025-06-20 16:28:49.732 WARN 25272 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : removeAbandoned is true, not use in production. 2025-06-20 16:28:49.737 INFO 25272 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited 2025-06-20 16:28:50.070 WARN 25272 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined in URL [jar:file:/E:/Program%20Files/apache-maven-3.9.1/rep/io/springfox/springfox-spring-web/3.0.0/springfox-spring-web-3.0.0.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/E:/Program%20Files/apache-maven-3.9.1/rep/io/springfox/springfox-spring-webmvc/3.0.0/springfox-spring-webmvc-3.0.0.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Invalid mapping on handler class [com.gsww.jzfp.security.server.modules.sys.controller.RestLoginController]: public java.lang.String com.gsww.jzfp.security.common.base.BaseController.bindException() 2025-06-20 16:28:50.072 INFO 25272 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closing ... 2025-06-20 16:28:50.082 INFO 25272 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closed 2025-06-20 16:28:50.102 INFO 25272 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2025-06-20 16:28:50.105 INFO 25272 --- [eate-1297110671] com.alibaba.druid.pool.DruidDataSource : put physical connection to pool failed. 2025-06-20 16:28:50.117 INFO 25272 --- [ restartedMain] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2025-06-20 16:28:50.137 ERROR 25272 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined in URL [jar:file:/E:/Program%20Files/apache-maven-3.9.1/rep/io/springfox/springfox-spring-web/3.0.0/springfox-spring-web-3.0.0.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/E:/Program%20Files/apache-maven-3.9.1/rep/io/springfox/springfox-spring-webmvc/3.0.0/springfox-spring-webmvc-3.0.0.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Invalid mapping on handler class [com.gsww.jzfp.security.server.modules.sys.controller.RestLoginController]: public java.lang.String com.gsww.jzfp.security.common.base.BaseController.bindException() at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:801) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:224) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:929) ~[spring-context-5.3.31.jar:5.3.31] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591) ~[spring-context-5.3.31.jar:5.3.31] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.18.jar:2.7.18] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) [spring-boot-2.7.18.jar:2.7.18] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:409) [spring-boot-2.7.18.jar:2.7.18] at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-2.7.18.jar:2.7.18] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) [spring-boot-2.7.18.jar:2.7.18] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) [spring-boot-2.7.18.jar:2.7.18] at com.zdww.tpgg.auth.AuthApplication.main(AuthApplication.java:16) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_361] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_361] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_361] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_361] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) [spring-boot-devtools-2.7.18.jar:2.7.18] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/E:/Program%20Files/apache-maven-3.9.1/rep/io/springfox/springfox-spring-webmvc/3.0.0/springfox-spring-webmvc-3.0.0.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Invalid mapping on handler class [com.gsww.jzfp.security.server.modules.sys.controller.RestLoginController]: public java.lang.String com.gsww.jzfp.security.common.base.BaseController.bindException() at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:801) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:224) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1609) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1573) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1462) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1349) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:911) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:788) ~[spring-beans-5.3.31.jar:5.3.31] ... 24 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Invalid mapping on handler class [com.gsww.jzfp.security.server.modules.sys.controller.RestLoginController]: public java.lang.String com.gsww.jzfp.security.common.base.BaseController.bindException() at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1609) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1573) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1462) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1349) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:911) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:788) ~[spring-beans-5.3.31.jar:5.3.31] ... 41 common frames omitted Caused by: java.lang.IllegalStateException: Invalid mapping on handler class [com.gsww.jzfp.security.server.modules.sys.controller.RestLoginController]: public java.lang.String com.gsww.jzfp.security.common.base.BaseController.bindException() at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lambda$detectHandlerMethods$1(AbstractHandlerMethodMapping.java:288) ~[spring-webmvc-5.3.31.jar:5.3.31] at org.springframework.core.MethodIntrospector.lambda$selectMethods$0(MethodIntrospector.java:74) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:367) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:375) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.core.MethodIntrospector.selectMethods(MethodIntrospector.java:72) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:281) ~[spring-webmvc-5.3.31.jar:5.3.31] at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.processCandidateBean(AbstractHandlerMethodMapping.java:266) ~[spring-webmvc-5.3.31.jar:5.3.31] at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:225) ~[spring-webmvc-5.3.31.jar:5.3.31] at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:213) ~[spring-webmvc-5.3.31.jar:5.3.31] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:205) ~[spring-webmvc-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.31.jar:5.3.31] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.31.jar:5.3.31] ... 55 common frames omitted Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724) ~[na:1.8.0_361] at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531) ~[na:1.8.0_361] at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355) ~[na:1.8.0_361] at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286) ~[na:1.8.0_361] at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120) ~[na:1.8.0_361] at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72) ~[na:1.8.0_361] at java.lang.reflect.Executable.declaredAnnotations(Executable.java:599) ~[na:1.8.0_361] at java.lang.reflect.Executable.declaredAnnotations(Executable.java:597) ~[na:1.8.0_361] at java.lang.reflect.Executable.getDeclaredAnnotations(Executable.java:588) ~[na:1.8.0_361] at java.lang.reflect.Method.getDeclaredAnnotations(Method.java:630) ~[na:1.8.0_361] at org.springframework.core.annotation.AnnotationsScanner.getDeclaredAnnotations(AnnotationsScanner.java:454) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.core.annotation.AnnotationsScanner.isKnownEmpty(AnnotationsScanner.java:492) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.core.annotation.TypeMappedAnnotations.from(TypeMappedAnnotations.java:251) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.core.annotation.MergedAnnotations.from(MergedAnnotations.java:351) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.core.annotation.MergedAnnotations.from(MergedAnnotations.java:330) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.core.annotation.AnnotatedElementUtils.findAnnotations(AnnotatedElementUtils.java:800) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation(AnnotatedElementUtils.java:642) ~[spring-core-5.3.31.jar:5.3.31] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.createRequestMappingInfo(RequestMappingHandlerMapping.java:321) ~[spring-webmvc-5.3.31.jar:5.3.31] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getMappingForMethod(RequestMappingHandlerMapping.java:284) ~[spring-webmvc-5.3.31.jar:5.3.31] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getMappingForMethod(RequestMappingHandlerMapping.java:76) ~[spring-webmvc-5.3.31.jar:5.3.31] at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lambda$detectHandlerMethods$1(AbstractHandlerMethodMapping.java:284) ~[spring-webmvc-5.3.31.jar:5.3.31] ... 66 common frames omitted
06-22
异常描述: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724) at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531) at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355) at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286) at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120) at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72) at java.lang.reflect.Executable.declaredAnnotations(Executable.java:599) at java.lang.reflect.Executable.declaredAnnotations(Executable.java:597) at java.lang.reflect.Executable.getDeclaredAnnotations(Executable.java:588) at java.lang.reflect.Method.getDeclaredAnnotations(Method.java:630) at org.springframework.core.annotation.AnnotationsScanner.getDeclaredAnnotations(AnnotationsScanner.java:453) at org.springframework.core.annotation.AnnotationsScanner.isKnownEmpty(AnnotationsScanner.java:491) at org.springframework.core.annotation.TypeMappedAnnotations.from(TypeMappedAnnotations.java:251) at org.springframework.core.annotation.MergedAnnotations.from(MergedAnnotations.java:351) at org.springframework.core.annotation.MergedAnnotations.from(MergedAnnotations.java:330) at org.springframework.core.annotation.AnnotatedElementUtils.findAnnotations(AnnotatedElementUtils.java:800) at org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation(AnnotatedElementUtils.java:541)怎么解决
03-28
<think>嗯,用户遇到了一个Java异常:java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy。首先,我需要分析这个异常的原因和可能的解决方案。 首先,查看异常类型。ArrayStoreException通常发生在试图将错误类型的对象存储到对象数组中时。这里的详细消息提到了sun.reflect.annotation.TypeNotPresentExceptionProxy,这可能与注解处理有关,特别是在Spring框架中。 接下来看堆栈跟踪,问题发生在AnnotationParser.parseClassArray,说明在处理注解数组时出现了问题。可能的原因是某个注解引用了缺失的类,导致TypeNotPresentExceptionProxy被创建,当尝试将这个代理对象存入数组时,类型不匹配,从而抛出ArrayStoreException。 用户的应用涉及Spring框架,特别是在处理注解时,如AnnotatedElementUtils.hasAnnotation。这可能发生在类路径中缺少某个注解所依赖的类的情况下。例如,使用了某个需要额外库的Spring注解,但该库未正确引入。 可能的解决步骤包括: 1. 检查类路径是否完整,确保所有依赖项都存在。特别是查看是否有缺失的库或版本冲突。例如,Spring可能需要某个特定的库,而项目中没有包含。 2. 检查代码中的注解,确认是否有注解引用了不存在的类。例如,自定义注解或第三方库中的注解可能引用了其他未包含的类。 3. 使用Maven或Gradle的依赖树分析工具,查看是否存在依赖冲突或缺失。例如,运行mvn dependency:tree或gradle dependencies,找出问题所在。 4. 清理并重新构建项目,有时候旧的编译文件可能导致类加载问题。 5. 检查JDK版本是否兼容。某些注解可能在较新的JDK中出现问题,或者需要特定的编译器设置。 此外,考虑是否有动态生成注解的情况,或者使用了反射操作注解数组,导致类型不一致。 需要指导用户逐步排查这些可能性,确保所有相关依赖正确,注解使用正确,并处理任何缺失的类或版本问题。</think>这个异常通常发生在Java注解处理过程中遇到类缺失的情况。以下是分步排查和解决方案: 1. **检查类路径完整性** - 查看pom.xml/gradle.build中是否缺少依赖 - 特别检查与注解相关的依赖(如Spring Boot Starter系列) - 运行`mvn dependency:tree | grep "missing-class"`查找缺失类 2. **定位问题注解** - 检查堆栈涉及的方法/类上的注解声明 - 特别注意组合注解中的嵌套引用,例如: ```java @RestController // 检查是否引用了不存在的类 @ConditionalOnClass(MissingClass.class) // 显式类引用 ``` 3. **常见问题场景** ✅ 正确示例(完整依赖): ```xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> ``` ❌ 错误示例(缺少Jackson): ```java @JsonSerialize(using = MissingSerializer.class) // 需要jackson-databind public class MyBean {} ``` 4. **验证步骤** ```bash # Maven项目验证命令 mvn clean compile # 检查输出中是否有ClassNotFoundException # Gradle项目验证命令 gradle clean build --stacktrace ``` 5. **解决方案矩阵** | 问题类型 | 表现特征 | 解决方法 | |---------|---------|---------| | 直接依赖缺失 | 明确提示缺少某个类 | 添加对应依赖 | | 传递依赖冲突 | 存在多个版本号 | 使用`<exclusion>排除冲突版本 | | 条件化注解误用 | 使用@ConditionalXXX注解时条件不满足 | 检查条件表达式是否正确 | | 注解处理器问题 | 编译时出现错误 | 更新annotation-processor版本 | 6. **特殊案例处理** 当使用Spring Profile时,确保配置一致性: ```properties # application-dev.properties spring.config.activate.on-profile=dev missing.configuration=enabled # 确保这个配置存在的类在类路径中 ``` 建议使用IDEA的`Analyze Stacktrace`功能直接定位到问题注解所在位置。如果使用Spring Boot,可以尝试添加: ```java @SpringBootApplication(exclude = {ProblematicAutoConfiguration.class}) ``` 临时排除可疑的自动配置类来验证问题。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值