SpringBoot整合JavaMelody与MybatisPlus产生的问题解决
Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail ! Cause:com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Get proxy targetObject exception ! Cause:java.lang.NoSuchFieldException: jdkDynamicField
//sqlSessionFactory 当看到这个报错就知道是数据源没有找到,但是我这个服务本来是能正常启动的所以我就排除我数据源的问题,因为引入了 javaMelody与springboot的整合所以我认为应该是mybatisplus与javaMelody出现冲突,
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail ! Cause:com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Get proxy targetObject exception !
开始我引入的是spring boot 与javaMelody的starter
//原引入的版本
<dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-spring-boot-starter</artifactId>
<version>1.76.0</version>
</dependency>
//不引入了starter了直接引入jar了
<dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-core</artifactId>
<version>1.79.0</version>
</dependency>
在配置类中把javaMelody注册到spirng中
@Bean
//配置注册顺序
@Order(Integer.MAX_VALUE - 1)
public FilterRegistrationBean monitoringFilter() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new MonitoringFilter());
registration.addUrlPatterns("/*");
registration.setName("monitoring");
return registration;
}
//
/**
* 配置javamelody监听器sessionListener
*/
@Bean
public ServletListenerRegistrationBean<SessionListener> servletListenerRegistrationBean() {
ServletListenerRegistrationBean<SessionListener> slrBean = new ServletListenerRegistrationBean<SessionListener>();
slrBean.setListener(new SessionListener());
return slrBean;
}
然后项目正常启动问题解决