2022
04-06
04-06
Spring 中如何根据环境切换配置 @Profile
Spring根据环境切换配置@Profile我们实际开发中往往有多个环境,比如测试环境、开发环境、生产环境等;不同的环境往往配置也有区别,一直切换环境的配置很麻烦,Spring为我们提供了一个注解,可以快速切换环境配置。@Profile我们新建一个配置,作用是注册三个数据源,因为不同的环境使用的数据库一般不一样:@Configuration@PropertySource("classpath:/person.properties")publicclassMainConfigOfProfileimplementsEmbedd...
继续阅读 >
mybatisspring配置SqlSessionTemplate使用1.application.xml配置<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context"xmlns:dwr=...