baomidou / dynamic-datasource

dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务
https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611
Apache License 2.0
4.75k stars 1.19k forks source link

Dynamic Datasource not judging Jakarta EE namespace when using SPEL #471

Closed linghengqian closed 1 year ago

linghengqian commented 1 year ago

Please fill it out carefully, or it will be closed. 请认真填写,不然会直接关闭。

Enviroment

JDK Version(required):

SpringBoot Version(required):

dynamic-datasource-spring-boot-starter Version(required):

druid Version(optional):

Describe what happened

Expected Result:

Actual Result:

If there is an exception,or aop invalid,please attach the exception trace:

Caused by: jakarta.servlet.ServletException: Handler dispatch failed: java.lang.NoSuchMethodError: 'javax.servlet.http.HttpServletRequest org.springframework.web.context.request.ServletRequestAttributes.getRequest()'
    at app//org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1095)
    at app//org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:973)
    at app//org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1010)
    at app//org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:902)
    at app//jakarta.servlet.http.HttpServlet.service(HttpServlet.java:705)
    at app//org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:884)
    at app//org.springframework.test.web.servlet.TestDispatcherServlet.service(TestDispatcherServlet.java:72)
    at app//jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814)
    at app//org.springframework.mock.web.MockFilterChain$ServletFilterProxy.doFilter(MockFilterChain.java:165)
    at app//org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
    at app//org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:201)
    at app//com.lingh.dynamicdatasourcespeltest.SPELTest.lambda$testSPEL$0(SPELTest.java:67)
    at app//org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:49)
    ... 88 more
Caused by: java.lang.NoSuchMethodError: 'javax.servlet.http.HttpServletRequest org.springframework.web.context.request.ServletRequestAttributes.getRequest()'
    at com.baomidou.dynamic.datasource.processor.jakarta.DsJakartaSessionProcessor.doDetermineDatasource(DsJakartaSessionProcessor.java:43)
    at com.baomidou.dynamic.datasource.processor.DsProcessor.determineDatasource(DsProcessor.java:53)
    at com.baomidou.dynamic.datasource.processor.DsProcessor.determineDatasource(DsProcessor.java:60)
    at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.determineDatasourceKey(DynamicDataSourceAnnotationInterceptor.java:58)
    at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.invoke(DynamicDataSourceAnnotationInterceptor.java:47)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:752)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
    at com.lingh.dynamicdatasourcespeltest.service.spel.UserService$$SpringCGLIB$$0.selectSpelBySession(<generated>)
    at com.lingh.dynamicdatasourcespeltest.controller.UserController.session(UserController.java:23)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:207)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:152)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1080)
    ... 100 more

Steps to reproduce

linghengqian commented 1 year ago
linghengqian commented 1 year ago