滴滴顺风车注册要求认证通过了

在做spring+mybatiss时,自动扫描都配置正确了,却在运行时出现了如下错误。后来查看target/classes/.../dao/文件夹下,发现只有mapper的class文件,而没有xml文件,将对应的xml文件放到这个文件夹下运行就不会出现下面的错误。说明出现这个错误的原因是maven编译时没有将xml文件放进去。
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): blogs.hellomsg.fileupload.dao.UploadFileMapper.getFileWithHashCode
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 com.sun.proxy.$Proxy12.getFileWithHashCode(Unknown Source)
blogs.hellomsg.fileupload.service.impl.UploadFileServiceImpl.getFileWithHashCode(UploadFileServiceImpl.java:31)
blogs.hellomsg.test.TestMybatis.test1(TestMybatis.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
解决方法:
在pom.xml中添加如下代码:
&resources&
&resource&
&directory&src/main/java&/directory&
&includes&
&include&**/*.xml&/include&
&/includes&
&filtering&true&/filtering&
&/resource&
&/resources&
阅读(...) 评论()当使用mvn package打包项目的时候,抛出下面这个错误:
1 [ERROR] Unable to locate the Javac Compiler in:
D:\jdk\..\lib\tools.jar
3 Please ensure you are using JDK 1.4 or above and
4 not a JRE (the com.sun.tools.javac.Main class is required).
5 In most cases you can change the location of your Java
6 installation by setting the JAVA_HOME environment variable.
他妈的找不到编译器,环境变量也没问题,为什么提示的路径是那样的?接着我到IntelliJ IDEA 里去设置SDK,在classpath里没有lib目录下的tools.jar和其它jar包,只有jre/lib目录下的一些包,搞不懂为什么会这样子,然后手动把tools.jar和dt.jar加入classpath,重新mvn package还是不行。
他妈的都怒了。最后只好先运行一个包含main方法的类,估计是IDEA自己去设置了加载路径,main方法执行后,就可以打包了,他们的也不知道是怎么回事。
所以最终的解决方法是:
先运行包含main方法的类,或者整个项目编译一下,然后再mvn package就成功了。
----更新----
他妈的可能是编译的插件版本问题,使用的是maven3,但是他妈的编译插件的版本是2.3.2的,当时从其它地方直接copy的没注意到。
阅读(...) 评论()maven根据profile中定义的环境变量打包的设置详解 - 为程序员服务
为程序员服务
maven根据profile中定义的环境变量打包的设置详解
一个项目里总会有很多配置文件。而且一般都会有多套环境。开发的、测试的、正式的。而在这些不同的环境这些配置的值都会不一样。比如mail的配置、服务的url配置这些都是很常见的。所以在打包的时候就要根据environment来选不同的值或者配置文件。
比较常用的办法就是为不同的环境建立不同的配置文件目录。在打包的时候用对应的文件目录下的配置文件。
|-- resources
|-- product
以前用ant的时候打包的时候处理就比较方便。打包前copy一下对应目录下的配置文件覆盖target下的那些文件再打包就可以了。在刚开始用maven的时候就想要怎么解决,一直没有找到ant的这种方式的可行的办法。其实主要是按ant这种处理方法去思考了。只去想没有有cp这种target。其实在maven里用profile就可以解决了。对于不同的environment定义不同的profile就ok了,目录结构还是沿用原来的就可以。
在pom.xml里定义一个变量
&properties&
&package.environment&qa53&/package.environment&
&/properties&
这里定义的值是经常打包的一个profile,方便少敲点代码。然后定义一些profile
&profiles&
&id&product&/id&
&properties&
&package.environment&product&/package.environment&
&/properties&
&/profile&
&id&dev&/id&
&properties&
&package.environment&dev&/package.environment&
&/properties&
&/profile&
&id&qa&/id&
&properties&
&package.environment&qa&/package.environment&
&/properties&
&/profile&
&/profiles&
最后再修改一下打包的plugin,引用这个变量。
&groupId&org.apache.maven.plugins&/groupId&
&artifactId&maven-war-plugin&/artifactId&
&configuration&
&addMavenDescriptor&false&/addMavenDescriptor&
&/archive&
&webResources&
&resource&
&!-- this is relative to the pom.xml directory --&
&directory&src/main/resources/${package.environment}&/directory&
&targetPath&WEB-INF/classes&/targetPath&
&filtering&true&/filtering&
&/resource&
&/webResources&
&/configuration&
这里注意一个参数&filtering&true&/filtering&,一定要设置成true这样才会用对应environment目录下的配置文件覆盖原来的。ok。mvn package的时候就会用默认的qa53目录下的配置文件。如果要发布正式环境的包就运行。mvn -Pproduct package.
您可能的代码
相关聚客文章
荣誉:2083
相关专栏文章

我要回帖

更多关于 注册滴滴顺风车 的文章

 

随机推荐