idea开发mavenweb项⽬时,target⽬录中的dao中没有xml⽂
在开发maven web项⽬时,因为是ssm项⽬,所以在dao层⾥有xml⽂件,以前也是这么开发的,但今天就出现了⼀下的错误
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.dao.BaseDictMapper.findDictByCode
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
at $Proxy11.findDictByCode(Unknown Source)
at cn.service.CustomerServiceImpl.findDictByCode(CustomerServiceImpl.java:19)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at ansaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at ansaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:267)
at ansaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at $Proxy13.findDictByCode(Unknown Source)
ller.CustomerController.list(CustomerController.java:24)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
idea debug
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:601)
at org.hod.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.hod.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.hod.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.hod.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) at org.springframework.web.hod.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
at org.springframework.web.hod.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at at.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.tor.CoyoteAdapter.service(CoyoteAdapter.java:408)
at http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at at.util.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
at urrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at urrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
DEBUG [http-bio-9099-exec-9] - Returning cached instance of singleton bean 'sqlSessionFactory'
⼀开始看到这个错以为⾃⼰的把配置⽂件写错了,也就是什么名称写错了,可是从头检查⼀遍发现没有任何问题,这就很难受了,因为定位不到错误,所以这就是最尴尬的结果,最后仔细看过出现这个错误的所有原因发现,target中的dao层⾥的xml⽂件不见了,那么问题了,离解决它也就不远了,所以下⾯就是解决⽅案了
对于MAVEN项⽬,Eclipse会⾃动把项⽬src\main\java\⽬录下的配置⽂件(.xml)和资源⽂件(.properties)搬运到target⽬录下,⽽intellij idea默认是不会帮我们做这件事的。
<build>
<finalName>SSMDemo5</finalName>
<!--解决Intellij构建项⽬时,target/classes⽬录下不存在l⽂件-->
<resources>
<resource>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
在pom⽂件⾥把上⾯这段代码添加进去就好了,这段代码的意思就是把src/main/java⽬录下所有的xml
⽂件都包含进去,其中${basedir}是MAVEN的内置变量,表⽰项⽬根⽬录。同样,想包含其他什么⽂件,⽐如.properties⽂件,再加⼀个<include>标签类似的写法即可。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。