日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

在maven pom.xml中加载不同的properties ,如localhost 和 dev master等jdbc.properties 中的链接不一样...

發(fā)布時(shí)間:2023/12/18 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在maven pom.xml中加载不同的properties ,如localhost 和 dev master等jdbc.properties 中的链接不一样... 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

【參考】:maven pom.xml加載不同properties配置[轉(zhuǎn)]

?首先 看看效果:

點(diǎn)開我們項(xiàng)目中的Maven projects 后,會(huì)發(fā)現(xiàn)右側(cè) 我們profile有個(gè)可勾選選項(xiàng)。默認(rèn)勾選localhost。localhost對(duì)應(yīng)項(xiàng)目啟動(dòng)后,會(huì)加載配置左側(cè)localhost文件夾下面的jdbc.perperties 和 redis.properties。 對(duì)于項(xiàng)目中存在測(cè)試數(shù)據(jù)庫(kù)或者運(yùn)行數(shù)據(jù)庫(kù)的區(qū)分的時(shí)候 我們可以通過(guò)勾選快速切換。那么我們是如何實(shí)現(xiàn)的呢

一:在左側(cè)文件目錄項(xiàng)目 配置相對(duì)于的文件目錄,并且注釋掉你之前的加載 ,如圖所示,

配置好所需的jdbc 鏈接?? 需要注意的 (正確寫法)url=jdbc:mysql://127.0.0.1:3306/course_design?useUnicode=true&characterEncoding=UTF-8 中間的間隔符 必須用 & 替換掉之前寫的 (錯(cuò)誤寫法)url=jdbc:mysql://127.0.0.1:3306/course_design?useUnicode=true&characterEncoding=UTF-8

具體原因參考?? Caused by: org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 84; 對(duì)實(shí)體 "characterEncoding"

?

????????????????????????????????????????

?

?二:配置 pom.xml

?

<!--配置profiles--><profiles><profile><id>localhost</id><!--默認(rèn)勾選設(shè)置--><activation><activeByDefault>true</activeByDefault></activation><properties><env>localhost</env></properties></profile><profile><id>dev</id><properties><env>dev</env></properties></profile><profile><id>master</id><properties><env>master</env></properties></profile></profiles><build>......................................</build>

?

?

<build>
.............................
<!--指定待加載的文件位置--><filters><filter>configs/${env}/jdbc.properties</filter><filter>configs/${env}/redis.properties</filter></filters><!--指定需要這些加載數(shù)據(jù)的 配置文件位置--><resources><resource><directory>src/main/resources</directory><includes><include>**/**</include></includes><filtering>true</filtering></resource></resources></build>

?

理論上 這個(gè)時(shí)候 以及在pom,xml中 配置完成了 點(diǎn)擊編譯之后 如果 正常是可以的

但我這里報(bào)錯(cuò)了? 3 字節(jié)的 UTF-8 序列的字節(jié) 3 無(wú)效 ? 后來(lái)查詢資料 發(fā)現(xiàn)還需要配置一個(gè)utf-8編譯 【參考】http://blog.csdn.net/lzupb/article/details/53008481

<!-- resource插件 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-resources-plugin</artifactId><version>2.6</version><configuration><encoding>UTF-8</encoding></configuration></plugin>

?

?其實(shí)后來(lái) 還有一個(gè)問(wèn)題 就是

  • :?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;?對(duì)實(shí)體?"characterEncoding"?的引用必須以?';'?分隔符結(jié)尾。? 這樣的的一個(gè)異常
  • 這個(gè)時(shí)候 前面介紹的jdbc url寫法就解決了? 把&? 變成 &amp; 就好了

    ?

    轉(zhuǎn)載于:https://www.cnblogs.com/luffyu/p/6646110.html

    創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

    總結(jié)

    以上是生活随笔為你收集整理的在maven pom.xml中加载不同的properties ,如localhost 和 dev master等jdbc.properties 中的链接不一样...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。