国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
ApplicationContext中profile指定解讀
方法一:system.setProperty,在文中指定
如果ApplicationContext.xml中出現(xiàn)兩套beans profile應(yīng)該如何確定使用是哪套數(shù)據(jù)庫(kù)
[java]
<!-- production/local development環(huán)境 -->
<beans profile="production,development,test1,functional1">
<context:property-placeholder
ignore-unresolvable="true" location="classpath*:/application.properties" />
<!-- 簡(jiǎn)單data source -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- 初始化數(shù)據(jù)結(jié)構(gòu) -->
<jdbc:initialize-database data-source="dataSource"
ignore-failures="ALL">
<jdbc:script location="classpath:sql/h2/schema.sql" />
</jdbc:initialize-database>
</beans>
<!-- unit test環(huán)境,functional test環(huán)境 -->
<beans profile="test,functional">
<context:property-placeholder
ignore-resource-not-found="true" location="classpath*:/application.test.properties" />
<!-- 簡(jiǎn)單data source -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- 初始化數(shù)據(jù)結(jié)構(gòu) -->
<jdbc:initialize-database data-source="dataSource"
ignore-failures="ALL">
<jdbc:script location="classpath:sql/h2/schema.sql" />
</jdbc:initialize-database>
<!-- 初始化測(cè)試數(shù)據(jù) -->
<bean class="org.springside.modules.test.data.DataInitializer"
lazy-init="false">
<property name="dataSource" ref="dataSource" />
<property name="dataFile" value="/data/sample-test-data.xml" />
</bean>
</beans>
如上代碼:
寫(xiě)單元測(cè)試的時(shí)候,所有的單元測(cè)試用例繼承于SpringTransactionalTestCase,這是springside-core-4.0.0.RC3-sources.jar中,注意在類(lèi)上有標(biāo)簽:@ActiveProfiles("test"),這就指定了他使用的datasource配置是test profile的那一套
[java]
/**
* Copyright (c) 2005-2012 springside.org.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
package org.springside.modules.test.spring;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
/**
*
* @author calvin
*/
@ActiveProfiles("test")
public abstract class SpringTransactionalTestCase extends AbstractTransactionalJUnit4SpringContextTests {
protected DataSource dataSource;
@Override
@Autowired
public void setDataSource(DataSource dataSource) {
super.setDataSource(dataSource);
this.dataSource = dataSource;
}
}
而在真正的執(zhí)行方法中使用
[java]
System.setProperty("spring.profiles.active", "production");
來(lái)指定,使用的dataservice是profile production的那yita
方法二:在web.xml中指定
1.在Spring配置文件applicationContext.xml中定義兩組環(huán)境
Java代碼  
<beans profile="production">
<!-- 生成環(huán)境 -->
</beans>
<beans profile="test">
<!-- 測(cè)試環(huán)境 -->
</beans>
2.在web.xml中,設(shè)定使用哪種環(huán)境
Java代碼  
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>production</param-value>
</context-param>
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Spring MVC 入門(mén)
Spring3自定義環(huán)境配置 <beans profile=“”>
【Struts2 Spring3 Hibernate3】SSH框架整合實(shí)現(xiàn)CRUD
spring整合MyBatis思路
詳解Spring的配置文件
spring總結(jié)
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服