今天使用Maven和Mybatis,在Eclipse上开发j2ee的程序。本人刚学Mybatis,对Maven还算熟悉,看过书,用的时间不长。本想试下Mybatis的selectList,结果程序编译通过,运行时报错:
郁闷!
之前见过SQLException报错,说ClassNotFound的或者链接打不开的,可就是没见过
java.sql.SQLException: No suitable driver found for http://maven.apache.org
的,我重新把java代码看了一遍,并没有在java代码中发现http://maven.apache.org,使用Maven的mvn clean compile一遍,发现问题依旧,猛然心想,去target里看看Mybatis的configuration配置文件吧,结果找到原因了!
我的Mybatis的配置文件源码如下:
可经过Maven的mvn compile之后,变成了:
发现问题了吧?
是的,maven把Mybatis的${url}替换成http://maven.apache.org了!
为什么呢?
在maven的compile之前,有一个阶段(phase)是process-resources,这时resources插件会把src/main/resources里的xml用到的${XXX}变量替换成设定的值,而url值碰巧在项目pom文件中定义了:
又碰巧,我把Mybatis的配置文件放到src/main/resouces目录底下了……然后悲剧就发生了。
如何解决:
不让maven过滤resources目录下的Mybatis配置文件,及其mapper文件!
修改工程的POM文件:
让maven不过滤mybatis文件夹下的东西就可以了。
注意:我的mybatis的配置文件被我放到src/main/resouces/mybatis文件夹下了。
分享到:
相关推荐
Maven更新问题 今天Maven在更新的时候发现... http://maven.aliyun.com/nexus/content/repositories/central/ central junit junit Address/ http://jcenter.bintray.com/ central alimaven aliyun maven htt
org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration) 解决方案: 第一种方式 war项目 <groupId>org.apache....
org.apache.commons.commons-math3:3.6.1
1) Error injecting constructor, java.lang.NoSuchMethodError: org.apache.maven.model.validation.DefaultModelValidator: method 'void ()' not found at org.jetbrains.idea.maven.server.embedder....
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project
The most up-to-date documentation can be found at http://maven.apache.org/. Release Notes ------------- The full list of changes can be found at http://maven.apache.org/release-notes.html. ...
commons-lang3.3.1.jar、Apache Commons包中的一个,包含了一些数据类型工具类,是java.lang.*的扩展。必须使用的jar包。为JRE5.0+的更好的版本所提供 Jar文件包含的类: META-INF/MANIFEST.MFMETA-INF/LICENSE....
Failure to transfer org.codehaus.plexus:plexus-archiver:pom:1.0 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update ...
hive 开发UDF 使用maven工程 引发jar包缺失 hive 开发UDF 使用maven工程 引发jar包缺失
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.1.0</version> <phase>package</phase> <goal>shade</goal> </goals> implementation=...
赠送jar包:mybatis-paginator-1.2.15.jar; 赠送原API文档:mybatis-paginator-1.2.15-javadoc.jar; 赠送源代码:mybatis-paginator-1.2.15-sources.jar; 赠送Maven依赖信息文件:mybatis-paginator-1.2.15.pom;...
Maven坐标:org.mybatis:mybatis:3.5.9; 标签:mybatis、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,...
Downloading from central: https://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml 很奇怪,我的maven仓库配置了私有库,,并且在maven setting.xml中配置了mirror...
If you are a Java developer or a manager who has experience with Apache Maven and want to extend your knowledge, then this is the ideal book for you. Apache Maven Cookbook is for those who want to ...
idea创建Maven项目时,报错显示Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.0.2:resources,并且Maven插件内看不到 mybatis-generator。如下图: 折腾了好久发现配置放错地方了,...
The most up-to-date documentation can be found at https://maven.apache.org/. Release Notes ------------- The full list of changes can be found at https://maven.apache.org/docs/history.html. ...
META-INF/maven/org.mybatis.caches/mybatis-ehcache/pom.properties META-INF/maven/org.mybatis.caches/mybatis-ehcache/pom.xml org.mybatis.caches.ehcache.EhcacheCache.class org.mybatis.caches.ehcache....
org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration) 网上更新eclipse插件的网址都失效了找了好久才有个离线版 ...
apache-maven-3.9.0-bin.tar.gz
基于SpringMVC+Spring+MyBatis+Maven项目案例.zip基于SpringMVC+Spring+MyBatis+Maven项目案例.zip基于SpringMVC+Spring+MyBatis+Maven项目案例.zip基于SpringMVC+Spring+MyBatis+Maven项目案例.zip基于SpringMVC+...