最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

淺談xml配置spring profiles的幾個注意點(diǎn)

 更新時間:2019年07月24日 10:29:56   作者:bluehtt  
這篇文章主要介紹了淺談xml配置spring profiles的幾個注意點(diǎn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

先貼正確配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:task="http://www.springframework.org/schema/task"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
      http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

  <aop:aspectj-autoproxy></aop:aspectj-autoproxy>
  <task:annotation-driven/>

  <import resource="spring-datasource.xml"/>
  <import resource="spring-hessian-server.xml"/>
  <import resource="spring-remoting-dis.xml"/>
  <import resource="spring-remoting-worldeye.xml"/>
  <import resource="spring-activemq.xml"/>
  <import resource="spring-cxf-client.xml"/>

  <!-- 開發(fā)配置 -->
  <beans profile="dev">
    <context:property-placeholder location="classpath:config/application.properties, classpath:config/application-dev.properties"/>
    <import resource="spring-hadoop-dev.xml"/>
  </beans>

  <!-- 測試配置 -->
  <beans profile="test">
    <context:property-placeholder location="classpath:config/application.properties, classpath:config/application-prd.properties, classpath:config/application-test.properties"/>
    <import resource="spring-hadoop-test.xml"/>
  </beans>

  <!-- 線上配置 -->
  <beans profile="prd">
    <context:property-placeholder location="classpath:config/application.properties, classpath:config/application-prd.properties"/>
    <import resource="spring-hadoop.xml"/>
  </beans>
</beans>

一. xml標(biāo)簽的xsd版本

spring-beans.xsd 文件不要指定版本,也可以使用高版本(起碼是3.1),原因是 spring profile 是3.1版本開始的。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"

    ......
    
    xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
      http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

二. dispatcherServlet文件配置

web.xml中配置了 DispatcherServlet 的 contextConfigLocation,需要在 spring-dispatch.xml 添加 spring profile 的配置,配置項(xiàng)同上。

  <!-- profile配置 -->
  <context-param>
    <param-name>spring.profiles.active</param-name>
    <param-value>prd</param-value>
  </context-param>

  <!-- Spring配置 -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      classpath:config/spring/spring-context.xml
      classpath:config/spring/spring-security.xml
    </param-value>
  </context-param>

  ......

  <!-- Spring Dispatcher配置 -->
  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
        classpath:config/spring/spring-hessian-server.xml
        classpath:config/spring/spring-dispatch.xml
        classpath:config/spring/spring-security.xml
      </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Idea插件安裝和管理方式

    Idea插件安裝和管理方式

    這篇文章主要介紹了Idea插件安裝和管理方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • 同時使用@LoadBalanced?@RefreshScope注解負(fù)載均衡失效分析

    同時使用@LoadBalanced?@RefreshScope注解負(fù)載均衡失效分析

    這篇文章主要為大家介紹了同時使用@LoadBalanced?@RefreshScope負(fù)載均衡失效問題分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • 淺析如何使用Swagger生成帶權(quán)限控制的API文檔

    淺析如何使用Swagger生成帶權(quán)限控制的API文檔

    當(dāng)涉及到權(quán)限控制時,如何生成既安全又詳細(xì)的?API?文檔就成了一個關(guān)鍵問題,所以這篇文章小編就來和大家好好聊聊如何用?Swagger?來生成帶有權(quán)限控制的?API?文檔吧
    2025-02-02
  • springboot使用dubbo和zookeeper代碼實(shí)例

    springboot使用dubbo和zookeeper代碼實(shí)例

    這篇文章主要介紹了springboot使用dubbo和zookeeper代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-11-11
  • 詳解如何為SpringBoot Web應(yīng)用的日志方便追蹤

    詳解如何為SpringBoot Web應(yīng)用的日志方便追蹤

    在Web應(yīng)用程序領(lǐng)域,有效的請求監(jiān)控和可追溯性對于維護(hù)系統(tǒng)完整性和診斷問題至關(guān)重要,SpringBoot是一種用于構(gòu)建Java應(yīng)用程序的流行框架,在本文中,我們探討了在SpringBoot中向日志添加唯一ID的重要性,需要的朋友可以參考下
    2023-11-11
  • java.lang.ArrayIndexOutOfBoundsException數(shù)組越界異常問題解決

    java.lang.ArrayIndexOutOfBoundsException數(shù)組越界異常問題解決

    這篇文章主要給大家介紹了關(guān)于java.lang.ArrayIndexOutOfBoundsException數(shù)組越界異常問題解決的相關(guān)資料,數(shù)組越界訪問是一個非常嚴(yán)重的問題,文中通過圖文將解決的辦法介紹的非常詳細(xì),需要的朋友可以參考下
    2024-01-01
  • Java多線程--讓主線程等待所有子線程執(zhí)行完畢在執(zhí)行

    Java多線程--讓主線程等待所有子線程執(zhí)行完畢在執(zhí)行

    Java主線程等待所有子線程執(zhí)行完畢在執(zhí)行,其實(shí)在我們的工作中經(jīng)常的用到,本篇文章就介紹了Java多線程--讓主線程等待所有子線程執(zhí)行完畢在執(zhí)行,有需要的可以了解一下。
    2016-11-11
  • 用Eclipse生成JPA元模型的方法

    用Eclipse生成JPA元模型的方法

    下面小編就為大家?guī)硪黄肊clipse生成JPA元模型的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-08-08
  • Java中的構(gòu)造方法和方法重載完整代碼

    Java中的構(gòu)造方法和方法重載完整代碼

    在Java編程中,構(gòu)造方法用于初始化對象,而方法重載允許同一個類中存在多個同名方法但參數(shù)不同,文中通過代碼及圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2024-10-10
  • mybatis?plus配置自動create_time和update_time方式

    mybatis?plus配置自動create_time和update_time方式

    在處理數(shù)據(jù)時,注意時間類型的轉(zhuǎn)換非常重要,不同編程環(huán)境和數(shù)據(jù)庫對時間數(shù)據(jù)的處理方式各異,因此在數(shù)據(jù)遷移或日常處理中需謹(jǐn)慎處理時間格式,個人經(jīng)驗(yàn)表明,了解常用的時間轉(zhuǎn)換函數(shù)和方法能有效避免錯誤,提高工作效率,希望這些經(jīng)驗(yàn)?zāi)転榇蠹規(guī)韼椭?/div> 2024-09-09

最新評論

乳山市| 田阳县| 紫云| 岳西县| 英德市| 彰化市| 巴彦县| 苍溪县| 石楼县| 普洱| 青州市| 武穴市| 壤塘县| 江西省| 烟台市| 泽库县| 浏阳市| 阜城县| 山西省| 金堂县| 红原县| 麻城市| 巫溪县| 沧州市| 商水县| 旬阳县| 横峰县| 甘泉县| 呼和浩特市| 万山特区| 广饶县| 中山市| 黔江区| 连城县| 张家川| 南宁市| 临桂县| 三明市| 巴林左旗| 西乌珠穆沁旗| 邻水|