spring总文件

文件名:applicationContext.xml

 <?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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- 加载系统配置文件 -->
<context:property-placeholder location="classpath:*.properties" /> <!-- 扫描注解 -->
<context:component-scan base-package="com.bjpowernode.p2p.service" /> <!-- 导入数据相关配置 -->
<import resource="applicationContext-datasource.xml" />
<!-- 导入 redis 配置 -->
<import resource="applicationContext-redis.xml" />
<!-- 导入服务提供者配置 -->
<import resource="applicationContext-dubbo-provider.xml"/>
</beans>

数据源配置文件

文件名:applicationContext-datasource.xml

 <?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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- 配置数据库连接,阿里数据源 druid 连接池 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<property name="url" value="jdbc:mysql://192.168.127.128:3306/p2p?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</bean> <!-- MyBatis sqlSessionFactory 配置 mybatis -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis-configuration.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- scan for mappers and let them be autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.bjpowernode.p2p.mapper"/>
<property name="sqlSessionFactory" ref="sqlSessionFactory"/>
</bean> <!-- 事务相关控制 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean> <tx:annotation-driven transaction-manager="transactionManager"/> <tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 对业务层所有方法添加事务,除了以 get、find、select 开始的 -->
<tx:method name="*" isolation="DEFAULT" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
<!-- 查询操作没有必要开启事务,给只读事务添加一个属性 read-only -->
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="select*" read-only="true"/>
<tx:method name="query*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- Service 层事务控制 -->
<aop:config>
<aop:pointcut id="pointcut" expression="execution(* com.bjpowernode.p2p.service.**.*.*(..))"/>
<aop:advisor pointcut-ref="pointcut" advice-ref="txAdvice"/>
</aop:config>
</beans>

dubbo配置

文件名:applicationContext-dubbo-provider.xml

<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <!-- 服务提供者:应用名称 -->
<dubbo:application name="dataservice"/> <!-- 配置 zookeeper 注册中心 -->
<dubbo:registry protocol="zookeeper" address="192.168.127.128:2181"/> <!--产品业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.LoanInfoService" ref="loanInfoServiceImpl" version="1.0.0" timeout="15000"></dubbo:service> <!--用户业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.UserService" ref="userServiceImpl" version="1.0.0" timeout="15000"></dubbo:service> <!--投资业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.BidInfoService" ref="bidInfoServiceImpl" version="1.0.0" timeout="15000"></dubbo:service> <!--帐户业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.user.FinanceAccountService" ref="financeAccountServiceImpl" version="1.0.0" timeout="15000"></dubbo:service> <!--redis业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.RedisService" ref="redisServiceImpl" version="1.0.0" timeout="15000"></dubbo:service> <!--收益业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.IncomeRecordService" ref="incomeRecordServiceImpl" version="1.0.0" timeout="15000"></dubbo:service> <!--充值业务-->
<dubbo:service interface="com.bjpowernode.p2p.service.loan.RechargeRecordService" ref="rechargeRecordServiceImpl" version="1.0.0" timeout="15000"></dubbo:service> </beans>

redis配置

文件名:applicationContext-redis.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"> <!-- jedis Connection Factory -->
<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:usePool="${redis.usePool}"
p:hostName="${redis.hostName}"
p:port="${redis.port}"
p:timeout="${redis.timeout}"
p:password="${redis.password}"/> <!-- redis template definition -->
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="jedisConnectionFactory"/>
</bean>
</beans>

log4j配置

文件名:log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration status="debug">
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<ThresholdFilter level="debug" onMatch="ACCEPT"
onMismatch="ACCEPT"/>
<PatternLayout pattern="[dataservice] %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
</Console>
<RollingFile name="RollingFile"
fileName="/opt/tomcat_dataservice/logs/dataservice.log"
filePattern="/opt/tomcat_dataservice/logs/$${date:yyyy-MM}/dataservice-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout
pattern="[dataservice] %d{yyyy-MM-dd 'at' HH:mm:ss z} %-5level %class{36} %L %M - %msg%xEx%n"/>
<SizeBasedTriggeringPolicy size="100MB"/>
</RollingFile>
</appenders>
<loggers>
<logger name="com.bjpowernode.p2p.mapper"
level="debug"/>
<root level="debug">
<appender-ref ref="Console"/>
<appender-ref ref="RollingFile"/>
</root>
</loggers>
</configuration>

mybatis配置

文件名:mybatis-configuration.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- log4j2 与 mybatis 集成,目的是打印出 sql 语句 -->
<settings>
<setting name="logImpl" value="LOG4J2"/>
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
</configuration>

redis属性配置

文件名:redis.properties

#redis config
redis.usePool=true
redis.hostName=192.168.127.128
redis.port=6379
redis.timeout=8000
redis.password=123456

web.xml的配置

文件名:web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="dataservice" version="3.0">
<display-name>dataservice application</display-name>
<!-- spring 监听器加载 applicationContext.xml 配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- spring 字符过滤器 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

02-springmvc分布式项目dataService项目配置的更多相关文章

  1. 【手摸手,带你搭建前后端分离商城系统】02 VUE-CLI 脚手架生成基本项目,axios配置请求、解决跨域问题

    [手摸手,带你搭建前后端分离商城系统]02 VUE-CLI 脚手架生成基本项目,axios配置请求.解决跨域问题. 回顾一下上一节我们学习到的内容.已经将一个 usm_admin 后台用户 表的基本增 ...

  2. SpringMVC,MyBatis项目中兼容Oracle和MySql的解决方案及其项目环境搭建配置、web项目中的单元测试写法、HttpClient调用post请求等案例

     要搭建的项目的项目结构如下(使用的框架为:Spring.SpingMVC.MyBatis): 2.pom.xml中的配置如下(注意,本工程分为几个小的子工程,另外两个工程最终是jar包): 其中 ...

  3. springmvc 项目完整示例01 需求与数据库表设计 简单的springmvc应用实例 web项目

    一个简单的用户登录系统 用户有账号密码,登录ip,登录时间 打开登录页面,输入用户名密码 登录日志,可以记录登陆的时间,登陆的ip 成功登陆了的话,就更新用户的最后登入时间和ip,同时记录一条登录记录 ...

  4. Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建(转)

    这篇文章主要讲解使用eclipse对Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建过程,包括里面步骤和里面的配置文件如何配置等等都会详细说明. 如果还没有搭建好环境( ...

  5. eclipse下SpringMVC+Maven+Mybatis+MySQL项目搭建

    这篇文章主要讲解使用eclipse对Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建过程,包括里面步骤和里面的配置文件如何配置等等都会详细说明. 接下来马上进入项目搭建 ...

  6. 使用SpringMVC搭建第一个项目

    概述 使用SpringMVC搭建第一个项目,入门教程,分享给大家. 详细 代码下载:http://www.demodashi.com/demo/10596.html 一.概述 1.什么是Spring ...

  7. Redisson实现分布式锁(3)—项目落地实现

    Redisson实现分布式锁(3)-项目落地实现 有关Redisson实现分布式锁前面写了两篇博客作为该项目落地的铺垫. 1.Redisson实现分布式锁(1)---原理 2.Redisson实现分布 ...

  8. 如何运行一个分布式的Maven项目

    本人也属于一个新手小白,之前在公司运行的项目也都不涉及到maven...但是前两天运行一个maven项目的时候发现,第一次接触这个还是蛮让我措手不及的.在这里整理下自己当时走的弯路,或者遇到的一些问题 ...

  9. SSM(Spring,SpringMVC,Mybatis)框架整合项目

    快速上手SSM(Spring,SpringMVC,Mybatis)框架整合项目 环境要求: IDEA MySQL 8.0.25 Tomcat 9 Maven 3.6 数据库环境: 创建一个存放书籍数据 ...

随机推荐

  1. c++ qsort函数应用

    C++ qsort在"iostream" c在头文件stdlib.h中,strcmp在string.h中.下列例子默认从小到大排序即(a>b返回>0),反之从小到大排序 ...

  2. delete file SVN commit error has no URL

    在提交SVN的时候遇到这个提交失败的提示: delete file SVN commit error has no URL 我的提交顺序是: 先在自己工程的文件夹删除 ->工程中删除 -> ...

  3. Jenkins - 【转】高效插件推荐

    特别说明:本文是在原文基础上的改写和添加,但总体不影响原文表达,特此说明. 原文链接 - Jenkins 高效插件推荐 | 运维生存时间 前言 开源版本的Jenkins具有三大能力: Master-S ...

  4. Mac上解决Chrome浏览器跨域问题

    最近做前端开发总是遇到一个很奇怪的现象,同一个AJAX请求,在Chrome里调试的时候就会提示跨域,但是在手机模拟器或者真机上调试的时候就不会,于是百度了一下,发现是Chrome的安全策略导致的,需要 ...

  5. 安装 Git 并连接 Github

    下载安装 Git, 下载地址:https://git-scm.com/download/win . 在命令行中输入 git 测试 Git 是否安装成功. 在桌面鼠标右击打开 Git Bash Here ...

  6. "在指定的 DSN 中,驱动程序和应用程序之间的体系结构不匹配" 问题总结

    最近C#连接ODBC数据源时,总是提示"[Microsoft][ODBC 驱动程序管理器] 在指定的 DSN 中,驱动程序和应用程序之间的体系结构不匹配",百度查询之后才知道原来是 ...

  7. numpy的divide函数

    和直接用/一样,都是矩阵的对应元素相除. 如果用*,那么是矩阵的对应元素相乘. 如果要实现矩阵乘法,用numpy的dot函数.

  8. sql注入知识点整理(基础版)

    sql注入知识点整理(基础版) 基本步骤 判断是否报错 判断闭合符号 判断注入类型 构建payload 手工注入或者编写脚本 基本注入类型 报错型注入 floor公式(结果多出一个1):and (se ...

  9. svn修改代码URL整合路径

    我们平常开发的代码都是在A服务器上整合的,最近A服务器突然无法访问了,所以今天我们更换了一下服务器.svn如何安装的就不说了,这里只介绍一下如何更换SVN URL的. 在你拿到URL后,在工作文件夹下 ...

  10. python 爬虫小案例

    爬取百度贴吧帖子信息 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: imcati import requests,re,time cl ...