01--springmvc分布式项目Web项目配置
阅读原文时间:2023年07月12日阅读:1

springmvc的配置文件,放在resources目录下:

文件名:applicationContext-mvc.xml


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 http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

 <!-- dispatcherServlet 截获所有 URL 请求 -->  
 <mvc:default-servlet-handler/>

 <!-- spring mvc 扫描包下的 controller -->  
 <context:component-scan base-package="com.bjpowernode.p2p.web"/>

 <!-- 配置注解驱动 -->  
 <mvc:annotation-driven/>

 <!-- 配置视图解析器 -->  
 <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
     <property name="prefix" value="/"/>  
     <property name="suffix" value=".jsp"/>  
 </bean>

spring总的配置文件

文件名:applicationContext.xml


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">

 <!-- 导入 spring mvc 配置 -->  
 <import resource="applicationContext-mvc.xml" />  
 <!-- 导入服务提供者配置 -->  
 <import resource="applicationContext-dubbo-consumer.xml"/>  

log4j配置

文件名称:log4j2.xml


dubbo的配置文件,消费者

文件名:applicationContext-dubbo-consumer.xml


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="p2p"/>

 <!-- 配置注册中心 -->  
 <dubbo:registry protocol="zookeeper" address="192.168.127.128:2181"/>

 <!--产品业务-->  
 <dubbo:reference id="loanInfoService" interface="com.bjpowernode.p2p.service.loan.LoanInfoService" version="1.0.0" check="false"></dubbo:reference>

 <!--用户业务-->  
 <dubbo:reference id="userService" interface="com.bjpowernode.p2p.service.loan.UserService" version="1.0.0" check="false"></dubbo:reference>

 <!--投资业务-->  
 <dubbo:reference id="bidInfoService" interface="com.bjpowernode.p2p.service.loan.BidInfoService" version="1.0.0" check="false"></dubbo:reference>

 <!--帐户业务-->  
 <dubbo:reference id="financeAccountService" interface="com.bjpowernode.p2p.service.user.FinanceAccountService" version="1.0.0" check="false"></dubbo:reference>

 <!--redis业务-->  
 <dubbo:reference id="redisService" interface="com.bjpowernode.p2p.service.loan.RedisService" version="1.0.0" check="false"></dubbo:reference>

 <!--收益业务-->  
 <dubbo:reference id="incomeRecordService" interface="com.bjpowernode.p2p.service.loan.IncomeRecordService" version="1.0.0" check="false"></dubbo:reference>

 <!--充值业务-->  
 <dubbo:reference id="rechargeRecordService" interface="com.bjpowernode.p2p.service.loan.RechargeRecordService" version="1.0.0" timeout="15000"></dubbo:reference>

WEB_INF下的配置文件web.xml配置

文件名:web.xml


http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app\_3\_0.xsd" id="WebApp\_ID" version="3.0"> p2p encodingFilter org.springframework.web.filter.CharacterEncodingFilter encoding UTF-8 encodingFilter /* dispatcher org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:applicationContext.xml 1 dispatcher / dispatcher /index index

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器