青橙商城配置文件
所有项目共有的配置,在common模块资源下,分别有:spring加载所有配置文件、zookeeper地址和端口、logj4
[XML] 纯文本查看 复制代码 <context:property-placeholder location="classpath*:*.properties"/>
[XML] 纯文本查看 复制代码 zookeeper.address=127.0.0.1:2181
[XML] 纯文本查看 复制代码 ### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.err
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file mylog.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=c:\\mylog.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=debug, stdout
common_service模块资源下,加载的有:spring加载dataSource、加载dubbo
[XML] 纯文本查看 复制代码
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="maxActive" value="10"/>
<property name="minIdle" value="5" />
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageHelper">
<property name="properties" >
<value>
dialect=mysql
</value>
</property>
</bean>
</array>
</property>
</bean>
<bean class="tk.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.qingcheng.dao"/>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
[XML] 纯文本查看 复制代码 <dubbo:application name="${dubbo.application}"/><!--goods资源下配置-->
<dubbo:protocol name="dubbo" port="${dubbo.port}"/><!--goods资源下配置-->
<dubbo:registry protocol="zookeeper" address="${zookeeper.address}"/><!--common资源下配置-->
<dubbo:annotation package="com.qingcheng.service.impl"/>
最后把每个服务的配置文件放在模块的资源下,配置文件有dubbo.properties和db.properties
其实是把加载配置资源和依赖注入分解开来,将服务模块中相同的DataSource依赖注入和Dubbo注入放到一个单独的模块,不同的配置文件分开。
|