SSM-SSM整合异常 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.y

 

    最近博主在做一个作业调度系统,用到了 Spring 与  Mybaits 以及 Thrift ,

在搭建整合框架的时候遇到了一个小问题 :

 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

 

先将问题的解决方法记录如下:

 

问题出现的原因:

   在配置MVN 编译的时候,没有将 xxxMapper.xml  作为配置文件编译进去,导致执行时   xxxMapper.xml  找不到。

 

问题的出错提示:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.yaobaling.dmp.schedule.mapper.DmpTagsConditionMapper.selectAll
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.(MapperMethod.java:196) ~[mybatis-3.3.0.jar:3.3.0]
	at org.apache.ibatis.binding.MapperMethod.(MapperMethod.java:44) ~[mybatis-3.3.0.jar:3.3.0]
	at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59) ~[mybatis-3.3.0.jar:3.3.0]
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) ~[mybatis-3.3.0.jar:3.3.0]
	at com.sun.proxy.$Proxy15.selectAll(Unknown Source) ~[?:?]
	at com.yaobaling.dmp.schedule.service.impl.DmpTagsConditionServiceImpl.callRemoteThriftByJobID(DmpTagsConditionServiceImpl.java:27) ~[classes/:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
	at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_45]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_45]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_45]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_45]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_45]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_45]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_45]

 

 

=======================================================================

 

我们去看下 target 下的编译生成 :

SSM-SSM整合异常 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.y_第1张图片

可以看到 mapper 所对应的 xml 文件并没有打包进来

 

我们再看下原始的代码目录:

SSM-SSM整合异常 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.y_第2张图片

可以看到原始目录是有 xml 文件的,这样可以看出是 xml 的问题 。

 

=========================================================================

解决方法:

 由于项目是 maven 组织的,我们需要把 xml 文件 作为资源 打包进来。

 

原本的 pom.xml  中的 build 模块:


        
            
                src/main/resources
                
                    **/*.properties
                    **/*.xml
                
            
            
                
                
                    
                
            
        
        
            
                maven-assembly-plugin
                
                    src/main/assembly/assembly.xml
                    UTF-8
                
                
                
                    
                        make-assembly
                        package
                    
                
            
            
                org.apache.maven.plugins
                maven-compiler-plugin
                3.1
                
                    1.8
                    1.8
                    utf-8
                
            
        
    

。。。

SSM-SSM整合异常 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.y_第3张图片

可以看到需要将 src/main/java/ 下面所有的 xml 文件打包进来。

 

修改过后的build 模块:


        
            
                src/main/resources
                
                    **/*.properties
                    **/*.xml
                
            
            
                src/main/java
                
                    **/*.xml
                
            
        
        
            
                maven-assembly-plugin
                
                    src/main/assembly/assembly.xml
                    UTF-8
                
                
                
                    
                        make-assembly
                        package
                    
                
            
            
                org.apache.maven.plugins
                maven-compiler-plugin
                3.1
                
                    1.8
                    1.8
                    utf-8
                
            
        
    

 

再次编译执行:

大吉大利,晚上吃鸡~

 

你可能感兴趣的:(SSM-SSM整合异常 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.y)