大兴网站制作,手机软件商城下载app,工程造价信息网电子版,网站地址查询域名【参考】#xff1a;maven pom.xml加载不同properties配置[转] 首先 看看效果#xff1a; 点开我们项目中的Maven projects 后#xff0c;会发现右侧 我们profile有个可勾选选项。默认勾选localhost。localhost对应项目启动后#xff0c;会加载配置左侧localhost文件夹下面… 【参考】maven pom.xml加载不同properties配置[转] 首先 看看效果 点开我们项目中的Maven projects 后会发现右侧 我们profile有个可勾选选项。默认勾选localhost。localhost对应项目启动后会加载配置左侧localhost文件夹下面的jdbc.perperties 和 redis.properties。 对于项目中存在测试数据库或者运行数据库的区分的时候 我们可以通过勾选快速切换。那么我们是如何实现的呢 一在左侧文件目录项目 配置相对于的文件目录并且注释掉你之前的加载 如图所示 配置好所需的jdbc 链接 需要注意的 正确写法urljdbc:mysql://127.0.0.1:3306/course_design?useUnicodetrueamp;characterEncodingUTF-8 中间的间隔符 必须用 amp; 替换掉之前写的 错误写法urljdbc:mysql://127.0.0.1:3306/course_design?useUnicodetrueamp;characterEncodingUTF-8 具体原因参考 Caused by: org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 84; 对实体 characterEncoding 二配置 pom.xml !--配置profiles--profilesprofileidlocalhost/id!--默认勾选设置--activationactiveByDefaulttrue/activeByDefault/activationpropertiesenvlocalhost/env/properties/profileprofileiddev/idpropertiesenvdev/env/properties/profileprofileidmaster/idpropertiesenvmaster/env/properties/profile/profilesbuild....................................../build build.............................
!--指定待加载的文件位置--filtersfilterconfigs/${env}/jdbc.properties/filterfilterconfigs/${env}/redis.properties/filter/filters!--指定需要这些加载数据的 配置文件位置--resourcesresourcedirectorysrc/main/resources/directoryincludesinclude**/**/include/includesfilteringtrue/filtering/resource/resources/build 理论上 这个时候 以及在pom,xml中 配置完成了 点击编译之后 如果 正常是可以的 但我这里报错了 3 字节的 UTF-8 序列的字节 3 无效 后来查询资料 发现还需要配置一个utf-8编译 【参考】http://blog.csdn.net/lzupb/article/details/53008481 !-- resource插件 --plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-resources-plugin/artifactIdversion2.6/versionconfigurationencodingUTF-8/encoding/configuration/plugin 其实后来 还有一个问题 就是 : Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 30 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 84; 对实体 characterEncoding 的引用必须以 ; 分隔符结尾。 这样的的一个异常这个时候 前面介绍的jdbc url写法就解决了 把 变成 amp 就好了 转载于:https://www.cnblogs.com/luffyu/p/6646110.html