锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲日韩在线观看,亚洲国产中文字幕在线观看,国产亚洲av人片在线观看http://www.tkk7.com/paulwong/category/55108.htmlzh-cnSun, 17 Dec 2023 12:04:15 GMTSun, 17 Dec 2023 12:04:15 GMT60Micro Fronthttp://www.tkk7.com/paulwong/archive/2023/12/14/451321.htmlpaulwongpaulwongThu, 14 Dec 2023 01:58:00 GMThttp://www.tkk7.com/paulwong/archive/2023/12/14/451321.htmlhttp://www.tkk7.com/paulwong/comments/451321.htmlhttp://www.tkk7.com/paulwong/archive/2023/12/14/451321.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/451321.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/451321.htmlhttps://medium.com/starbugs/%E5%BE%AE%E6%9C%8D%E5%8B%99%E5%BE%88%E5%A4%AF-%E9%82%A3%E4%BD%A0%E6%9C%89%E8%81%BD%E9%81%8E%E5%BE%AE%E5%89%8D%E7%AB%AF%E5%97%8E-%E5%88%9D%E6%8E%A2-micro-frontends-%E6%9E%B6%E6%A7%8B-e0a8469be601

涓璧鋒帰璦?Micro Frontends 鐨勪笘鐣?br />https://blog.techbridge.cc/2019/01/12/micro-frontends-concept/


Micro Frontends
extending the microservice idea to frontend development
https://micro-frontends.org/


paulwong 2023-12-14 09:58 鍙戣〃璇勮
]]>
SPRING CLOUD CONFIG鏈夌晫闈㈢殑閰嶇疆綆$悊涓績http://www.tkk7.com/paulwong/archive/2021/10/07/436000.htmlpaulwongpaulwongThu, 07 Oct 2021 08:55:00 GMThttp://www.tkk7.com/paulwong/archive/2021/10/07/436000.htmlhttp://www.tkk7.com/paulwong/comments/436000.htmlhttp://www.tkk7.com/paulwong/archive/2021/10/07/436000.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/436000.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/436000.html

https://dyc87112.github.io/spring-cloud-config-admin/

paulwong 2021-10-07 16:55 鍙戣〃璇勮
]]>
寰湇鍔℃灦鏋勮璁℃ā寮?/title><link>http://www.tkk7.com/paulwong/archive/2021/01/06/435766.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Wed, 06 Jan 2021 06:44:00 GMT</pubDate><guid>http://www.tkk7.com/paulwong/archive/2021/01/06/435766.html</guid><wfw:comment>http://www.tkk7.com/paulwong/comments/435766.html</wfw:comment><comments>http://www.tkk7.com/paulwong/archive/2021/01/06/435766.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/paulwong/comments/commentRss/435766.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/paulwong/services/trackbacks/435766.html</trackback:ping><description><![CDATA[寰湇鍔℃灦鏋勫強璁捐妯″紡<br /><a target="_blank">http://dockone.io/article/9680</a><br /><br />寰湇鍔℃灦鏋?0涓渶閲嶈鐨勮璁℃ā寮?br /><a target="_blank">https://developer.51cto.com/art/202012/635852.htm</a><br /><br />GitHub鏍囨槦127K錛佸瓧鑺傚唴閮ㄥ繀鍒?#8220;寰湇鍔℃灦鏋勮璁℃ā寮?#8221;<br /><a target="_blank">https://blog.csdn.net/a159357445566/article/details/110006542</a><br /><br />寰湇鍔℃灦鏋勫強鍏舵渶閲嶈鐨?0涓璁℃ā寮?br /><a target="_blank">https://www.infoq.cn/article/Kdw69bdimlX6FSGz1bg3</a><br /><br />Effective Microservices: 10 Best Practices<br /><a target="_blank">https://towardsdatascience.com/effective-microservices-10-best-practices-c6e4ba0c6ee2</a><br /><br />Microservice Architecture and its 10 Most Important Design Patterns<br /><a target="_blank">https://towardsdatascience.com/microservice-architecture-and-its-10-most-important-design-patterns-824952d7fa41</a><br /><br /><br /><br /><br /><img src ="http://www.tkk7.com/paulwong/aggbug/435766.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/paulwong/" target="_blank">paulwong</a> 2021-01-06 14:44 <a href="http://www.tkk7.com/paulwong/archive/2021/01/06/435766.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍩轟簬Spring Cloud鐨勫揩閫熷紑鍙戣剼鎵嬫灦&鏈浣沖疄璺墊葷粨http://www.tkk7.com/paulwong/archive/2020/10/09/435685.htmlpaulwongpaulwongFri, 09 Oct 2020 02:48:00 GMThttp://www.tkk7.com/paulwong/archive/2020/10/09/435685.htmlhttp://www.tkk7.com/paulwong/comments/435685.htmlhttp://www.tkk7.com/paulwong/archive/2020/10/09/435685.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/435685.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/435685.html Spring Cloud 浣犳噦鐨?/td> Keycloak 寰湇鍔¤璇佹巿鏉?/td> Jenkins 鎸佺畫闆嗘垚 SonarQube 浠g爜璐ㄩ噺鎺у埗

https://gitee.com/itmuch/spring-cloud-yes

paulwong 2020-10-09 10:48 鍙戣〃璇勮
]]>
Spring Cloud寮傛鍦烘櫙鍒嗗竷寮忎簨鍔℃庢牱鍋氾紵璇曡瘯RocketMQhttp://www.tkk7.com/paulwong/archive/2020/07/15/435596.htmlpaulwongpaulwongWed, 15 Jul 2020 02:33:00 GMThttp://www.tkk7.com/paulwong/archive/2020/07/15/435596.htmlhttp://www.tkk7.com/paulwong/comments/435596.htmlhttp://www.tkk7.com/paulwong/archive/2020/07/15/435596.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/435596.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/435596.html
鍒嗗竷寮忕殑鍦烘櫙涓嬶紝璁㈠崟鏈嶅姟鍦ㄤ竴涓狫VM涓嬶紝縐垎鏈嶅姟鍦ㄥ彟涓涓狫VM涓嬶紝涓よ呰濡備綍鎵嶈兘杈懼埌鏁版嵁涓鑷達紙鍘熷瓙錛夋э紵


https://zlt2000.gitee.io/2019-09-23-rocketmq-transaction/


paulwong 2020-07-15 10:33 鍙戣〃璇勮
]]>
!!zlt-microservices-platformhttp://www.tkk7.com/paulwong/archive/2020/07/15/435595.htmlpaulwongpaulwongWed, 15 Jul 2020 02:15:00 GMThttp://www.tkk7.com/paulwong/archive/2020/07/15/435595.htmlhttp://www.tkk7.com/paulwong/comments/435595.htmlhttp://www.tkk7.com/paulwong/archive/2020/07/15/435595.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/435595.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/435595.html1. 鎬諱綋鏋舵瀯鍥?/h2>

mark


2. 鍔熻兘浠嬬粛

mark




https://github.com/zlt2000/microservices-platform 

https://zlt2000.gitee.io/

浜у搧鏂囨。錛堜粯璐癸紝寰俊鐧誨綍錛夛細
https://www.kancloud.cn/zlt2000/microservices-platform




paulwong 2020-07-15 10:15 鍙戣〃璇勮
]]>
APM璧勬簮http://www.tkk7.com/paulwong/archive/2019/12/30/435006.htmlpaulwongpaulwongMon, 30 Dec 2019 08:50:00 GMThttp://www.tkk7.com/paulwong/archive/2019/12/30/435006.htmlhttp://www.tkk7.com/paulwong/comments/435006.htmlhttp://www.tkk7.com/paulwong/archive/2019/12/30/435006.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/435006.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/435006.htmlhttps://my.oschina.net/10000000000/blog/3119697

鐩戞帶綆$悊涔婼pring Boot Admin浣跨敤
https://my.oschina.net/xiedeshou/blog/2051625


https://my.oschina.net/janlle/blog/3040749

paulwong 2019-12-30 16:50 鍙戣〃璇勮
]]>
寰湇鍔?緗戝叧http://www.tkk7.com/paulwong/archive/2019/12/30/435005.htmlpaulwongpaulwongMon, 30 Dec 2019 08:44:00 GMThttp://www.tkk7.com/paulwong/archive/2019/12/30/435005.htmlhttp://www.tkk7.com/paulwong/comments/435005.htmlhttp://www.tkk7.com/paulwong/archive/2019/12/30/435005.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/435005.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/435005.htmlhttps://felord.cn/kong-api-gateway.html

浜戝師鐢熺綉鍏?Kong 鍜孠ong 綆$悊UI Konga鐨勫畬鍏ㄥ畨瑁呮敾鐣?br />https://felord.cn/kong-and-konga-install.html






paulwong 2019-12-30 16:44 鍙戣〃璇勮
]]>
浣跨敤Spring Cloud Security OAuth2鎼緩鎺堟潈鏈嶅姟http://www.tkk7.com/paulwong/archive/2016/09/16/431797.htmlpaulwongpaulwongFri, 16 Sep 2016 10:22:00 GMThttp://www.tkk7.com/paulwong/archive/2016/09/16/431797.htmlhttp://www.tkk7.com/paulwong/comments/431797.htmlhttp://www.tkk7.com/paulwong/archive/2016/09/16/431797.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/431797.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/431797.htmlSpring Cloud Security OAuth2 鏄?Spring 瀵?OAuth2 鐨勫紑婧愬疄鐜幫紝浼樼偣鏄兘涓嶴pring Cloud鎶鏈嚎鏃犵紳闆嗘垚錛屽鏋滃叏閮ㄤ嬌鐢ㄩ粯璁ら厤緗紝寮鍙戣呭彧闇瑕佹坊鍔犳敞瑙e氨鑳藉畬鎴?OAuth2 鎺堟潈鏈嶅姟鐨勬惌寤恒?/p>

1. 娣誨姞渚濊禆

鎺堟潈鏈嶅姟鏄熀浜嶴pring Security鐨勶紝鍥犳闇瑕佸湪欏圭洰涓紩鍏ヤ袱涓緷璧栵細

<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-security</artifactId>
</dependency>

<dependency>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-starter-oauth2</artifactId>
 </dependency>


鍓嶈呬負 Security錛屽悗鑰呬負Security鐨凮Auth2鎵╁睍銆?/p>

2. 娣誨姞娉ㄨВ鍜岄厤緗?/h1>

鍦ㄥ惎鍔ㄧ被涓坊鍔?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">@EnableAuthorizationServer娉ㄨВ錛?br />

@SpringBootApplication
@EnableAuthorizationServer
public class AlanOAuthApplication {
    public static void main(String[] args) {
        SpringApplication.run(AlanOAuthApplication.class, args);
    }
}


瀹屾垚榪欎簺鎴戜滑鐨勬巿鏉冩湇鍔℃渶鍩烘湰鐨勯鏋跺氨宸茬粡鎼緩瀹屾垚浜嗐備絾鏄鎯寵窇閫氭暣涓祦紼嬶紝鎴戜滑蹇呴』鍒嗛厤 client_idclient_secret鎵嶈銆係pring Security OAuth2鐨勯厤緗柟娉曟槸緙栧啓@Configuration綾葷戶鎵?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">AuthorizationServerConfigurerAdapter錛岀劧鍚庨噸鍐?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">void configure(ClientDetailsServiceConfigurer clients)鏂規硶錛屽錛?br />

@Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory() // 浣跨敤in-memory瀛樺偍
                .withClient("client") // client_id
                .secret("secret") // client_secret
                .authorizedGrantTypes("authorization_code") // 璇lient鍏佽鐨勬巿鏉冪被鍨?/span>
                .scopes("app"); // 鍏佽鐨勬巿鏉冭寖鍥?/span>
    }


3. 鎺堟潈嫻佺▼

璁塊棶鎺堟潈欏甸潰錛?br />

localhost:8080/oauth/authorize?client_id=client&response_type=code&redirect_uri=http://www.baidu.com


姝ゆ椂嫻忚鍣ㄤ細璁╀綘杈撳叆鐢ㄦ埛鍚嶅瘑鐮侊紝榪欐槸鍥犱負 Spring Security 鍦ㄩ粯璁ゆ儏鍐典笅浼氬鎵鏈塙RL娣誨姞Basic Auth璁よ瘉銆傞粯璁ょ殑鐢ㄦ埛鍚嶄負user, 瀵嗙爜鏄殢鏈虹敓鎴愮殑錛屽湪鎺у埗鍙版棩蹇椾腑鍙互鐪嬪埌銆?/p>

oauth2

鐢婚铏界劧寰堢畝闄嬶紝浣嗘槸鍩烘湰鍔熻兘閮藉叿澶囦簡銆傜偣鍑?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">Authorize鍚庯紝嫻忚鍣ㄥ氨浼氶噸瀹氬悜鍒扮櫨搴︼紝騫跺甫涓?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">code鍙傛暟錛?/p>

榪欓噷鍐欏浘鐗囨弿榪? title=

鎷垮埌code浠ュ悗錛屽氨鍙互璋冪敤

POST/GET http://client:secret@localhost:8080/oauth/token
  • 1

鏉ユ崲鍙?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">access_token浜嗭細

curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: application/x-www-form-urlencoded" -d 'grant_type=authorization_code&code=Li4NZo&redirect_uri=http://www.baidu.com' "http://client:secret@localhost:8080/oauth/token"

榪斿洖濡備笅錛?br />

{
  "access_token": "32a1ca28-bc7a-4147-88a1-c95abcc30556",
  "token_type": "bearer",
  "expires_in": 2591999,
  "scope": "app"
}

鍒版鎴戜滑鏈鏈鍩烘湰鐨勬巿鏉冩湇鍔″氨鎼緩瀹屾垚浜嗐傜劧鑰岋紝榪欎粎浠呮槸涓猟emo錛屽鏋滆鍦ㄧ敓浜х幆澧冧腑浣跨敤錛岃繕闇瑕佸仛鏇村鐨勫伐浣溿?/p>

4. 浣跨敤MySQL瀛樺偍access_token鍜宑lient淇℃伅

鎶婃巿鏉冩湇鍔″櫒涓殑鏁版嵁瀛樺偍鍒版暟鎹簱涓茍涓嶉毦錛屽洜涓?Spring Cloud Security OAuth 宸茬粡涓烘垜浠璁″ソ浜嗕竴濂桽chema鍜屽搴旂殑DAO瀵硅薄銆備絾鍦ㄤ嬌鐢ㄤ箣鍓嶏紝鎴戜滑闇瑕佸厛瀵圭浉鍏崇殑綾繪湁涓瀹氱殑浜嗚В銆?/p>

4.1 鐩稿叧鎺ュ彛

Spring Cloud Security OAuth2閫氳繃DefaultTokenServices綾繪潵瀹屾垚token鐢熸垚銆佽繃鏈熺瓑 OAuth2 鏍囧噯瑙勫畾鐨勪笟鍔¢昏緫錛岃?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">DefaultTokenServices鍙堟槸閫氳繃TokenStore鎺ュ彛瀹屾垚瀵圭敓鎴愭暟鎹殑鎸佷箙鍖栥傚湪涓婇潰鐨刣emo涓紝TokenStore鐨勯粯璁ゅ疄鐜頒負InMemoryTokenStore錛屽嵆鍐呭瓨瀛樺偍銆?瀵逛簬Client淇℃伅錛?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">ClientDetailsService鎺ュ彛璐熻矗浠庡瓨鍌ㄤ粨搴撲腑璇誨彇鏁版嵁錛屽湪涓婇潰鐨刣emo涓粯璁や嬌鐢ㄧ殑涔熸槸InMemoryClientDetialsService瀹炵幇綾匯傝鍒拌繖閲屽氨鑳界湅鍑猴紝瑕佹兂浣跨敤鏁版嵁搴撳瓨鍌紝鍙渶瑕佹彁渚涜繖浜涙帴鍙g殑瀹炵幇綾誨嵆鍙傚簡騫哥殑鏄紝妗嗘灦宸茬粡涓烘垜浠啓濂絁DBC瀹炵幇浜嗭紝鍗?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">JdbcTokenStore鍜?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">JdbcClientDetailsService銆?/p>

4.2 寤鴻〃

瑕佹兂浣跨敤榪欎簺JDBC瀹炵幇錛岄鍏堣寤鴻〃銆傛鏋朵負鎴戜滑鎻愬墠璁捐濂戒簡schema, 鍦╣ithub涓婏細https://github.com/spring-projects/spring-security-oauth/blob/master/spring-security-oauth2/src/test/resources/schema.sql

鍦ㄤ嬌鐢ㄨ繖濂楄〃緇撴瀯涔嬪墠瑕佹敞鎰忕殑鏄紝瀵逛簬MySQL鏉ヨ錛岄粯璁ゅ緩琛ㄨ鍙ヤ腑涓婚敭鏄痸archar(255)綾誨瀷錛屽湪mysql涓墽琛屼細鎶ラ敊錛屽師鍥犳槸mysql瀵箆archar涓婚敭闀垮害鏈夐檺鍒躲傛墍浠ヨ繖閲屾敼鎴?28鍗沖彲銆傚叾嬈★紝璇彞涓細鏈夋煇浜涘瓧孌典負LONGVARBINARY綾誨瀷錛屽畠瀵瑰簲mysql鐨?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">blob綾誨瀷錛屼篃闇瑕佷慨鏀逛竴涓嬨?/p>

4.3 閰嶇疆

鏁版嵁搴撳緩濂藉悗錛屼笅涓姝ュ氨鏄厤緗鏋朵嬌鐢↗DBC瀹炵幇銆傛柟娉曡繕鏄紪鍐?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">@Configuration綾葷戶鎵?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">AuthorizationServerConfigurerAdapter錛?br />

@Autowired
    private AuthenticationManager authenticationManager;

    @Autowired
    private DataSource dataSource;
    @Bean // 澹版槑TokenStore瀹炵幇
    public TokenStore tokenStore() {
        return new JdbcTokenStore(dataSource);
    }
    @Bean // 澹版槑 ClientDetails瀹炵幇
    public ClientDetailsService clientDetails() {
        return new JdbcClientDetailsService(dataSource);
    }
    @Override // 閰嶇疆妗嗘灦搴旂敤涓婅堪瀹炵幇
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        endpoints.authenticationManager(authenticationManager);
        endpoints.tokenStore(tokenStore());

        // 閰嶇疆TokenServices鍙傛暟
        DefaultTokenServices tokenServices = new DefaultTokenServices();
        tokenServices.setTokenStore(endpoints.getTokenStore());
        tokenServices.setSupportRefreshToken(false);
        tokenServices.setClientDetailsService(endpoints.getClientDetailsService());
        tokenServices.setTokenEnhancer(endpoints.getTokenEnhancer());
        tokenServices.setAccessTokenValiditySeconds( (int) TimeUnit.DAYS.toSeconds(30)); // 30澶?/span>
        endpoints.tokenServices(tokenServices);
    }

瀹屾垚榪欎簺鍚庯紝妗嗘灦灝變細灝嗕腑闂翠駭鐢熺殑鏁版嵁鍐欏埌mysql涓簡銆?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">oauth_client_details鏄痗lient琛紝鍙互鐩存帴鍦ㄨ琛ㄤ腑娣誨姞璁板綍鏉ユ坊鍔燾lient: 
榪欓噷鍐欏浘鐗囨弿榪? title=

4.4 闇瑕佹敞鎰忕殑鍦版柟

榪欓噷涓嶅緱涓嶈 Spring 璁捐鏈変竴涓钁╁湴鐨勬柟銆傛敞鎰忕湅oauth_access_token琛ㄦ槸瀛樻斁璁塊棶浠ょ墝鐨勶紝浣嗘槸騫舵病鏈夌洿鎺ュ湪瀛楁涓瓨鏀総oken銆係pring 浣跨敤OAuth2AccessToken鏉ユ娊璞′笌浠ょ墝鏈夊叧鐨勬墍鏈夊睘鎬э紝鍦ㄥ啓鍏ュ埌鏁版嵁搴撴椂錛?strong style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">Spring灝嗚瀵硅薄閫氳繃JDK鑷甫鐨勫簭鍒楀寲鏈哄埗搴忓垪鎴愬瓧鑺?/strong>鐩存帴淇濆瓨鍒頒簡璇ヨ〃鐨?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">token瀛楁涓備篃灝辨槸璇達紝濡傛灉鍙湅鏁版嵁琛ㄤ綘鏄湅涓嶅嚭access_token鐨勫兼槸澶氬皯錛岃繃鏈熸椂闂寸瓑淇℃伅鐨勩傝繖灝辯粰璧勬簮鏈嶅姟鍣ㄧ殑瀹炵幇甯︽潵浜嗛夯鐑︺傛垜浠殑璧勬簮鎻愪緵鏂瑰茍娌℃湁浣跨敤Spring Security錛屼篃涓嶆兂寮曞叆 Spring Security 鐨勪換浣曚緷璧栵紝榪欐椂鍊欏氨鍙兘灝?nbsp;DefaultOAuth2AccessToken鐨勬簮鐮乧opy鍒拌祫婧愭彁渚涙柟鐨勯」鐩腑錛岀劧鍚庤鍙?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">token瀛楁騫跺弽搴忓垪鍖栬繕鍘熷璞℃潵鑾峰彇token淇℃伅銆備絾鏄鏋滆繖鏍峰仛榪樹細閬囧埌鍙嶅簭鍒楀寲鍏煎鎬х殑闂錛屽叿浣撹В鍐蟲柟娉曞弬鑰冩垜鍙︿竴綃囧崥鏂?http://blog.csdn.net/neosmith/article/details/52539614

5. 鎬葷粨

鑷蟲涓涓兘鍦ㄧ敓浜х幆澧冧笅浣跨敤鐨勬巿鏉冩湇鍔″氨鎼緩濂戒簡銆傚叾瀹炴垜浠湪瀹為檯浣跨敤鏃跺簲璇ラ傚綋瀹氬埗JdbcTokenStore鎴?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">ClientDetailsService鏉ュ疄閫傚簲涓氬姟闇瑕侊紝鐢氳嚦鍙互鐩存帴浠?寮濮嬪疄鐜版帴鍙o紝瀹屽叏涓嶇敤妗嗘灦鎻愪緵鐨勫疄鐜般傚彟澶栵紝Spring 鐩存帴灝?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">DefaultOAuth2AccessToken搴忓垪鍖栨垚瀛楄妭淇濆瓨鍒版暟鎹簱涓殑璁捐錛屾垜璁や負鏄潪甯鎬笉鍚堢悊鐨勩傛垨璁歌璁¤呯殑鍒濊》鏄繚瀵?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">access_token錛屼絾鏄氳繃鍔犲瘑鐨勬柟娉曚篃鍙互瀹炵幇錛屽畬鍏ㄤ笉搴旇鐩存帴鎵斿瓧鑺傘備笉榪囬氳繃瀹氬埗TokenStore鎺ュ彛錛屾垜浠彲浠ヤ嬌鐢ㄨ嚜宸辯殑琛ㄧ粨鏋勮屼笉鎷樻償浜庨粯璁ゅ疄鐜般?br />
http://blog.csdn.net/tracker_w/article/category/6360121

http://blog.csdn.net/neosmith/article/details/52539927



paulwong 2016-09-16 18:22 鍙戣〃璇勮
]]>
浣跨敤Spring Cloud Feign浣滀負HTTP瀹㈡埛绔皟鐢ㄨ繙紼婬TTP鏈嶅姟http://www.tkk7.com/paulwong/archive/2016/09/16/431796.htmlpaulwongpaulwongFri, 16 Sep 2016 10:13:00 GMThttp://www.tkk7.com/paulwong/archive/2016/09/16/431796.htmlhttp://www.tkk7.com/paulwong/comments/431796.htmlhttp://www.tkk7.com/paulwong/archive/2016/09/16/431796.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/431796.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/431796.html鍦⊿pring Cloud Netflix鏍堜腑錛屽悇涓井鏈嶅姟閮芥槸浠TTP鎺ュ彛鐨勫艦寮忔毚闇茶嚜韜湇鍔$殑錛屽洜姝ゅ湪璋冪敤榪滅▼鏈嶅姟鏃跺氨蹇呴』浣跨敤HTTP瀹㈡埛绔傛垜浠彲浠ヤ嬌鐢↗DK鍘熺敓鐨?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">URLConnection銆丄pache鐨?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">Http Client銆丯etty鐨勫紓姝TTP Client, Spring鐨?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">RestTemplate銆備絾鏄紝鐢ㄨ搗鏉ユ渶鏂逛究銆佹渶浼橀泤鐨勮繕鏄灞濬eign浜嗐?/p>

Feign綆浠?/h1>

Feign鏄竴縐嶅0鏄庡紡銆佹ā鏉垮寲鐨凥TTP瀹㈡埛绔傚湪Spring Cloud涓嬌鐢‵eign, 鎴戜滑鍙互鍋氬埌浣跨敤HTTP璇鋒眰榪滅▼鏈嶅姟鏃惰兘涓庤皟鐢ㄦ湰鍦版柟娉曚竴鏍風殑緙栫爜浣撻獙錛屽紑鍙戣呭畬鍏ㄦ劅鐭ヤ笉鍒拌繖鏄繙紼嬫柟娉曪紝鏇存劅鐭ヤ笉鍒拌繖鏄釜HTTP璇鋒眰銆傛瘮濡傦細

@Autowired
private AdvertGropRemoteService service; // 榪滅▼鏈嶅姟

public AdvertGroupVO foo(Integer groupId) {
    return service.findByGroupId(groupId); // 閫氳繃HTTP璋冪敤榪滅▼鏈嶅姟
}

寮鍙戣呴氳繃service.findByGroupId()灝辮兘瀹屾垚鍙戦丠TTP璇鋒眰鍜岃В鐮丠TTP榪斿洖緇撴灉騫跺皝瑁呮垚瀵硅薄鐨勮繃紼嬨?/p>

Feign鐨勫畾涔?/h1>

涓轟簡璁〧eign鐭ラ亾鍦ㄨ皟鐢ㄦ柟娉曟椂搴旇鍚戝摢涓湴鍧鍙戣姹備互鍙婅姹傞渶瑕佸甫鍝簺鍙傛暟錛屾垜浠渶瑕佸畾涔変竴涓帴鍙o細

@FeignClient(name = "ea")  //  [A]
public interface AdvertGroupRemoteService {

    @RequestMapping(value = "/group/{groupId}", method = RequestMethod.GET) // [B]
    AdvertGroupVO findByGroupId(@PathVariable("groupId") Integer adGroupId) // [C]

    @RequestMapping(value = "/group/{groupId}", method = RequestMethod.PUT)
    void update(@PathVariable("groupId") Integer groupId, @RequestParam("groupName") String groupName)

A: @FeignClient鐢ㄤ簬閫氱煡Feign緇勪歡瀵硅鎺ュ彛榪涜浠g悊(涓嶉渶瑕佺紪鍐欐帴鍙e疄鐜?錛屼嬌鐢ㄨ呭彲鐩存帴閫氳繃@Autowired娉ㄥ叆銆?/p>

B: @RequestMapping琛ㄧず鍦ㄨ皟鐢ㄨ鏂規硶鏃墮渶瑕佸悜/group/{groupId}鍙戦?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">GET璇鋒眰銆?/p>

C: @PathVariable涓?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">SpringMVC涓搴旀敞瑙e惈涔夌浉鍚屻?/p>

Spring Cloud搴旂敤鍦ㄥ惎鍔ㄦ椂錛孎eign浼氭壂鎻忔爣鏈?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">@FeignClient娉ㄨВ鐨勬帴鍙o紝鐢熸垚浠g悊錛屽茍娉ㄥ唽鍒癝pring瀹瑰櫒涓傜敓鎴愪唬鐞嗘椂Feign浼氫負姣忎釜鎺ュ彛鏂規硶鍒涘緩涓涓?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">RequetTemplate瀵硅薄錛岃瀵硅薄灝佽浜咹TTP璇鋒眰闇瑕佺殑鍏ㄩ儴淇℃伅錛岃姹傚弬鏁板悕銆佽姹傛柟娉曠瓑淇℃伅閮芥槸鍦ㄨ繖涓繃紼嬩腑紜畾鐨勶紝Feign鐨勬ā鏉垮寲灝變綋鐜板湪榪欓噷銆?/p>

鍦ㄦ湰渚嬩腑錛屾垜浠皢Feign涓嶦ureka鍜孯ibbon緇勫悎浣跨敤錛?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">@FeignClient(name = "ea")鎰忎負閫氱煡Feign鍦ㄨ皟鐢ㄨ鎺ュ彛鏂規硶鏃惰鍚慐ureka涓煡璇㈠悕涓?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">ea鐨勬湇鍔★紝浠庤屽緱鍒版湇鍔RL銆?/p>

Feign鐨凟ncoder銆丏ecoder鍜孍rrorDecoder

Feign灝嗘柟娉曠鍚嶄腑鏂規硶鍙傛暟瀵硅薄搴忓垪鍖栦負璇鋒眰鍙傛暟鏀懼埌HTTP璇鋒眰涓殑榪囩▼錛屾槸鐢辯紪鐮佸櫒(Encoder)瀹屾垚鐨勩傚悓鐞嗭紝灝咹TTP鍝嶅簲鏁版嵁鍙嶅簭鍒楀寲涓簀ava瀵硅薄鏄敱瑙g爜鍣?Decoder)瀹屾垚鐨勩?/p>

榛樿鎯呭喌涓嬶紝Feign浼氬皢鏍囨湁@RequestParam娉ㄨВ鐨勫弬鏁拌漿鎹㈡垚瀛楃涓叉坊鍔犲埌URL涓紝灝嗘病鏈夋敞瑙g殑鍙傛暟閫氳繃Jackson杞崲鎴恓son鏀懼埌璇鋒眰浣撲腑銆傛敞鎰忥紝濡傛灉鍦?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">@RequetMapping涓殑method灝嗚姹傛柟寮忔寚瀹氫負POST錛岄偅涔堟墍鏈夋湭鏍囨敞瑙g殑鍙傛暟灝嗕細琚拷鐣ワ紝渚嬪錛?br />

@FeignClient(name = "ea")  //  [A]
public interface AdvertGroupRemoteService {

    @RequestMapping(value = "/group/{groupId}", method = RequestMethod.GET) // [B]
    AdvertGroupVO findByGroupId(@PathVariable("groupId") Integer adGroupId) // [C]

    @RequestMapping(value = "/group/{groupId}", method = RequestMethod.PUT)
    void update(@PathVariable("groupId") Integer groupId, @RequestParam("groupName") String groupName)

姝ゆ椂鍥犱負澹版槑鐨勬槸GET璇鋒眰娌℃湁璇鋒眰浣擄紝鎵浠?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">obj鍙傛暟灝變細琚拷鐣ャ?/p>

鍦⊿pring Cloud鐜涓嬶紝Feign鐨凟ncoder*鍙細鐢ㄦ潵緙栫爜娌℃湁娣誨姞娉ㄨВ鐨勫弬鏁?銆傚鏋滀綘鑷畾涔変簡Encoder, 閭d箞鍙湁鍦ㄧ紪鐮?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">obj鍙傛暟鏃舵墠浼氳皟鐢ㄤ綘鐨凟ncoder銆傚浜嶥ecoder, 榛樿浼氬鎵樼粰SpringMVC涓殑MappingJackson2HttpMessageConverter綾昏繘琛岃В鐮併傚彧鏈夊綋鐘舵佺爜涓嶅湪200 ~ 300涔嬮棿鏃禘rrorDecoder鎵嶄細琚皟鐢ㄣ侲rrorDecoder鐨勪綔鐢ㄦ槸鍙互鏍規嵁HTTP鍝嶅簲淇℃伅榪斿洖涓涓紓甯革紝璇ュ紓甯稿彲浠ュ湪璋冪敤Feign鎺ュ彛鐨勫湴鏂硅鎹曡幏鍒般傛垜浠洰鍓嶅氨閫氳繃ErrorDecoder鏉ヤ嬌Feign鎺ュ彛鎶涘嚭涓氬姟寮傚父浠ヤ緵璋冪敤鑰呭鐞嗐?/p>

Feign鐨凥TTP Client

Feign鍦ㄩ粯璁ゆ儏鍐典笅浣跨敤鐨勬槸JDK鍘熺敓鐨?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">URLConnection鍙戦丠TTP璇鋒眰錛屾病鏈夎繛鎺ユ睜錛屼絾鏄姣忎釜鍦板潃浼氫繚鎸佷竴涓暱榪炴帴錛屽嵆鍒╃敤HTTP鐨?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">persistence connection 銆傛垜浠彲浠ョ敤Apache鐨凥TTP Client鏇挎崲Feign鍘熷鐨刪ttp client, 浠庤岃幏鍙栬繛鎺ユ睜銆佽秴鏃舵椂闂寸瓑涓庢ц兘鎭伅鐩稿叧鐨勬帶鍒惰兘鍔涖係pring Cloud浠?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">Brixtion.SR5鐗堟湰寮濮嬫敮鎸佽繖縐嶆浛鎹紝棣栧厛鍦ㄩ」鐩腑澹版槑Apache HTTP Client鍜?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">feign-httpclient渚濊禆錛?br />

@RequestMapping(value = "/group/{groupId}", method = RequestMethod.GET)
void update(@PathVariable("groupId") Integer groupId, @RequestParam("groupName") String groupName, DataObject obj);

鐒跺悗鍦?code style="box-sizing: border-box; font-family: "Source Code Pro", monospace; font-size: 13.5px; padding: 2px 4px; color: #3f3f3f; white-space: nowrap; border-radius: 0px; margin: 0px; border: 0px; outline: 0px; vertical-align: baseline; word-break: break-word; background: rgba(128, 128, 128, 0.0745098);">application.properties涓坊鍔狅細

feign.httpclient.enabled=true

鎬葷粨

閫氳繃Feign錛?鎴戜滑鑳芥妸HTTP榪滅▼璋冪敤瀵瑰紑鍙戣呭畬鍏ㄩ忔槑錛屽緱鍒頒笌璋冪敤鏈湴鏂規硶涓鑷寸殑緙栫爜浣撻獙銆傝繖涓鐐逛笌闃塊噷Dubbo涓毚闇茶繙紼嬫湇鍔$殑鏂瑰紡綾諱技錛屽尯鍒湪浜嶥ubbo鏄熀浜庣鏈変簩榪涘埗鍗忚錛岃孎eign鏈川涓婅繕鏄釜HTTP瀹㈡埛绔傚鏋滄槸鍦ㄧ敤Spring Cloud Netflix鎼緩寰湇鍔★紝閭d箞Feign鏃犵枒鏄渶浣抽夋嫨銆?br />
http://blog.csdn.net/tracker_w/article/category/6360121
http://blog.csdn.net/neosmith/article/details/52449921



paulwong 2016-09-16 18:13 鍙戣〃璇勮
]]>
寰湇鍔℃鏋禨pring Cloudhttp://www.tkk7.com/paulwong/archive/2016/09/11/431788.htmlpaulwongpaulwongSun, 11 Sep 2016 12:49:00 GMThttp://www.tkk7.com/paulwong/archive/2016/09/11/431788.htmlhttp://www.tkk7.com/paulwong/comments/431788.htmlhttp://www.tkk7.com/paulwong/archive/2016/09/11/431788.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/431788.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/431788.html2016

paulwong 2016-09-11 20:49 鍙戣〃璇勮
]]>
JHipsterhttp://www.tkk7.com/paulwong/archive/2016/09/11/431787.htmlpaulwongpaulwongSun, 11 Sep 2016 08:40:00 GMThttp://www.tkk7.com/paulwong/archive/2016/09/11/431787.htmlhttp://www.tkk7.com/paulwong/comments/431787.htmlhttp://www.tkk7.com/paulwong/archive/2016/09/11/431787.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/431787.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/431787.htmlhttp://jhipster.cn/

paulwong 2016-09-11 16:40 鍙戣〃璇勮
]]>
spring cloud欏圭洰璇誨彇閰嶇疆綆$悊http://www.tkk7.com/paulwong/archive/2016/09/11/431785.htmlpaulwongpaulwongSun, 11 Sep 2016 08:26:00 GMThttp://www.tkk7.com/paulwong/archive/2016/09/11/431785.htmlhttp://www.tkk7.com/paulwong/comments/431785.htmlhttp://www.tkk7.com/paulwong/archive/2016/09/11/431785.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/431785.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/431785.htmlspring cloud config server閰嶇疆濂戒簡鏁版嵁搴撹繛鎺ヤ俊鎭紝榪欎釜欏圭洰璇誨彇config錛岃幏鍙栬繛鎺ヤ俊鎭傝繖閲屼互mybtis浣滀負鍒楀瓙銆備粠鏈嶅姟鍣ㄨ鍙杍dbc淇℃伅鍚庯紝榪愯mybatis紼嬪簭銆?br />
紜鏈嶅姟鏄惁鎴愬姛
http://localhost:8888/demo-config/test
{"name":"demo-config","profiles":["test"],"label":"master","version":"02d28ad4925aa9bd1bf8a48d2edbf04ce61aa45a","propertySources":[{"name":"https://git.oschina.net/penghaozhong/demo.git/demo-config-repo/demo-config-test.properties","source":{"jdbc.url":"jdbc:mysql://localhost:3306/demo?characterEncoding=UTF-8","jdbc.username":"root","jdbc.driver":"com.mysql.jdbc.Driver","jdbc.password":"xxxxxx","jdbc.type":"mysql"}}]}

    2. 閰嶇疆璇誨彇閰嶇疆鏂囦歡

  



鍦╞ootstrap.properties涓坊鍔犺鍙栭厤緗鐞嗙殑鍦板潃銆?br />
3. 璇誨彇閰嶇疆鏂囦歡灞炴э紝榪欓噷閲囩敤@ConfigurationProperties
/**
 * 璇誨彇鏁版嵁搴撻厤緗枃浠?br /> * 
@author penghaozhong
 *
 
*/
@ConfigurationProperties(prefix = DataSourceProperties.PREFIX, ignoreUnknownFields = false)
public  class  DataSourceProperties {
    
        public DataSourceProperties() {
        super();
    }
        //瀵瑰簲閰嶇疆鏂囦歡閲岀殑閰嶇疆閿?/span>
        public final static String PREFIX="jdbc";    
        
        private String type; 
        private String driver; 
        private String url; 
        private String username; 
        private String password;
        
        public String getType() {
            return type;
        }
        public void setType(String type) {
            this.type = type;
        }
        public String getDriver() {
            return driver;
        }
        public void setDriver(String driver) {
            this.driver = driver;
        }
        public String getUrl() {
            return url;
        }
        public void setUrl(String url) {
            this.url = url;
        }
        public String getUsername() {
            return username;
        }
        public void setUsername(String username) {
            this.username = username;
        }
        public String getPassword() {
            return password;
        }
        public void setPassword(String password) {
            this.password = password;
        }

}


4. 閰嶇疆mybatis
@Configuration
@MapperScan("com.phz.test.spring.cloud.demo")
@EnableConfigurationProperties(DataSourceProperties.class)
@EnableTransactionManagement
public class MybatisDataSource {

    // mybaits mapper xml鎼滅儲璺緞
    private final static String MAPPERLOCATIONS = "classpath:/mappings/**/*.xml";
    private final static String CONFIGLOCATION = "classpath:/mybatis-config.xml";

    @Autowired
    private  DataSourceProperties dataSourceProperties;
    private DruidDataSource datasource = null;

    @Bean(destroyMethod = "close")
    public  DataSource dataSource(){
        datasource = new DruidDataSource();  
        datasource.setUrl(dataSourceProperties.getUrl());
        datasource.setDbType(dataSourceProperties.getType());
        datasource.setDriverClassName(dataSourceProperties.getDriver());
        datasource.setUsername(dataSourceProperties.getUsername());
        datasource.setPassword(dataSourceProperties.getPassword());
        return datasource;
    }

    @PreDestroy
    public void close() {
        if(datasource != null){
            datasource.close();
        }
    }

    @Bean
    public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
        sqlSessionFactoryBean.setDataSource(dataSource());
        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        sqlSessionFactoryBean.setMapperLocations(resolver.getResources(MAPPERLOCATIONS));
        sqlSessionFactoryBean.setConfigLocation(resolver.getResource(CONFIGLOCATION));
        sqlSessionFactoryBean.setTypeAliasesPackage("com.phz.test.spring.cloud.demo.entity");
        return sqlSessionFactoryBean.getObject();
    }

    @Bean
    public PlatformTransactionManager transactionManager() {
        return new DataSourceTransactionManager(dataSource());
    }

}













paulwong 2016-09-11 16:26 鍙戣〃璇勮
]]>
MICROSERVICE 璧勬簮http://www.tkk7.com/paulwong/archive/2016/09/01/431723.htmlpaulwongpaulwongThu, 01 Sep 2016 13:46:00 GMThttp://www.tkk7.com/paulwong/archive/2016/09/01/431723.htmlhttp://www.tkk7.com/paulwong/comments/431723.htmlhttp://www.tkk7.com/paulwong/archive/2016/09/01/431723.html#Feedback0http://www.tkk7.com/paulwong/comments/commentRss/431723.htmlhttp://www.tkk7.com/paulwong/services/trackbacks/431723.html
涓昏鏈塭ureka鍋氭湇鍔″彂鐜般乧onfig鍋氬垎甯冨紡閰嶇疆銆亃uul鍋歛pi-gateway銆乫eign鍋氬鎴風璐熻澆鍧囪 銆乭ystrix鍋氭柇璺櫒銆乼urbine鍋氳仛鍚堢殑monitor銆乬raphite鍋氭寚鏍囩洃鎺с?/span>

http://blog.csdn.net/liaokailin/article/category/6212338


MICROSERVICE WITH SPRING-CLOUD.
https://github.com/kennyk65/Microservices-With-Spring-Student-Files




!!!spring-cloud-study
http://git.oschina.net/itmuch/spring-cloud-study

paulwong 2016-09-01 21:46 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲欧洲国产综合| 亚洲系列国产精品制服丝袜第| 亚洲日本一线产区和二线| 一级毛片在线免费看| 亚洲a在线视频视频| 亚洲成熟xxxxx电影| 美女视频黄a视频全免费网站色窝| 自拍偷自拍亚洲精品第1页| 4hu四虎免费影院www| 亚洲精品制服丝袜四区| 国产麻豆成人传媒免费观看| 久久精品国产精品亚洲艾草网| 亚洲小说图区综合在线| 免费观看一级毛片| 亚洲乱码中文论理电影| 两性色午夜免费视频| 亚洲av无码成人黄网站在线观看| 日韩精品人妻系列无码专区免费| 亚洲中文字幕在线第六区| a级精品九九九大片免费看| 亚洲A∨无码无在线观看| 国产免费丝袜调教视频| 亚洲日韩中文字幕无码一区| 免费一级毛片免费播放| 国产日韩AV免费无码一区二区| 18gay台湾男同亚洲男同| 韩国欧洲一级毛片免费| 中文字幕免费人成乱码中国| 中文字幕亚洲精品| 午夜精品在线免费观看| 香蕉免费在线视频| 亚洲精彩视频在线观看| 免费一级国产生活片| 永久免费av无码网站yy| 亚洲欧美自偷自拍另类视| 国产精品V亚洲精品V日韩精品| 新最免费影视大全在线播放| 亚洲bt加勒比一区二区| 免费在线观看日韩| 99久久免费观看| 看免费毛片天天看|