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

文件名:applicationContext-mvc.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:util="http://www.springframework.org/schema/util"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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
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> </beans>

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

log4j配置

文件名称:log4j2.xml

 <?xml version="1.0" encoding="UTF-8"?>
<configuration status="info">
<!--先定义所有的 appender-->
<appenders>
<!--这个输出控制台的配置-->
<Console name="Console" target="SYSTEM_OUT">
<!--控制台只输出 level 及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="ACCEPT"/>
<!--这个都知道是输出日志的格式-->
<PatternLayout pattern="[p2p] %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
</Console>
<!--这个会打印出所有的信息,每次大小超过 size,则这 size 大小的日
志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile name="RollingFile"
fileName="/opt/tomcat_licaihost/logs/app.log"
filePattern="/opt/tomcat_licaihost/logs/$${date:yyyy-MM}/app -%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout pattern="[p2p] %d{yyyy-MM-dd 'at' HH:mm:ss z} %-5level %class{36} %L %M - %msg%xEx%n"/>
<SizeBasedTriggeringPolicy size="300MB"/>
</RollingFile>
</appenders>
<!--然后定义 logger,只有定义了 logger 并引入 appender,appender 才会生效-->
<loggers>
<!--建立一个默认的 root 的 logger-->
<root level="info">
<appender-ref ref="Console"/>
<appender-ref ref="RollingFile"/>
</root>
</loggers>
</configuration>

dubbo的配置文件,消费者

文件名:applicationContext-dubbo-consumer.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="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> </beans>

WEB_INF下的配置文件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="WebApp_ID" version="3.0">
<!-- 应用名 -->
<display-name>p2p</display-name>
<!-- 字符过滤器,字符编码 UTF-8 -->
<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>
<!-- Spring mvc 分发 servlet -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/index</url-pattern>
</servlet-mapping>
<!-- 欢迎页,默认进入 index controller -->
<welcome-file-list>
<welcome-file>index</welcome-file>
</welcome-file-list>
</web-app>

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

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

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

  2. springmvc+maven搭建web项目之二 通过另一种方式配置spring

    1.创建maven web项目 2. 配置pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x ...

  3. SpringMVC框架下Web项目的搭建与部署

    这篇文章已被废弃. 现在,Deolin使用Maven构建项目,而不是下载Jar文件,使用Jetty插件调试项目,而不是外部启动Tomcat. SpringMVC比起Servlet/JSP方便了太多 W ...

  4. 最详尽的IntelliJ IDEA项目web项目搭建!!!!!!

    一.创建一个web项目(首次创建最麻烦) 1.保证安装好软件 2.双击打开软件-->新建一个项目 3.web项目选择如图,先建立一个空的项目空间来放置你的项目,这是一个区别 相当于myeclip ...

  5. springMVC WebApplicationInitializer 替代web.xml 配置Servlet 之原理

    Servlet 3.0之前 ,xml  配置 在过去搭建spring + springMCV ,首先第一步要做的是什么 ,就是要配置web.xml 文件 ,把springMVC 中的Servlet 加 ...

  6. springmvc+maven搭建web项目

    1.创建一个maven project 为spring1 2.进行项目的配置:默认的java 1.5 在properties中选择project facts项目进行配置,反选web之后修改java环境 ...

  7. MyBatis整合Spring+SpringMVC搭建一个web项目(SSM框架)

    本文讲解如何搭建一个SSM架构的web站点 [工具] IDEA.SqlYog.Maven [简述] 该项目由3个模块组成:dao(数据访问层).service(业务处理层).web(表现层) dao层 ...

  8. SpringMVC Memcached 搭建WEB项目缓存框架

    最近做的项目一直在使用memcached作为缓存来缓存各种数据,现在BOSS要在项目上加上缓存.并把任务交给我.便琢磨怎么解决这个问题. 看了很多文章,写的比较详尽靠谱的就是这篇了http://www ...

  9. 05.基于IDEA+Spring+Maven搭建测试项目--web.xml配置

    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" " ...

随机推荐

  1. idea中git远程版本回退

    idea中git远程版本回退 2017年10月15日 15:25:36 gomeplus 阅读数:19313 工作中遇到git远程仓库需要回退到历史版本的问题,根据网上的搜索结果结合自己的实践,整理了 ...

  2. EncryptionAndDecryptionC# 加密 解密

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  3. django 模板里面for循环和if常用的方法

    django 模板里面for循环常用的方法 {% for %} 允许我们在一个序列上迭代.与Python的for 语句的情形类似,循环语法是 for X in Y ,Y是要迭代的序列而X是在每一个特定 ...

  4. 【Python基础】lpthw - Exercise 46 项目骨架

    本节将会介绍如何构建一个项目骨架目录.骨架目录中会包含项目文件布局.自动测试代码.模块及安装脚本. 一.环境配置(win10) 1. 检查并确认自己只安装了一个python版本. cd ~ pytho ...

  5. core python

    一:正则表达式 闭包操作符 | 等同于 or   exp:a|b|c           . 匹配任意一个字符 (若匹配本字符,需转义使用 \.   不能匹配换行符\n及空字符串)    (^:匹配首 ...

  6. java application.properties 密码加密

    main方法 public static void main(String[] args) { BasicTextEncryptor textEncryptor = new BasicTextEncr ...

  7. POP与OOP编程模式对比

    面向过程:(procedure oriented programming 即:POP) 代表:C/C++ 向过程程序设计,它是以功能为中心来进行思考和组织的一种编程方式,强调的是系统的数据被加工和处理 ...

  8. 2019牛客暑期多校训练营(第五场)G - subsequeue 1 (一题我真的不会的题)

    layout: post title: 2019牛客暑期多校训练营(第五场)G - subsequeue 1 (一题我真的不会的题) author: "luowentaoaa" c ...

  9. CSP 俄罗斯方块(201604-2)

    问题描述 俄罗斯方块是俄罗斯人阿列克谢·帕基特诺夫发明的一款休闲游戏. 游戏在一个15行10列的方格图上进行,方格图上的每一个格子可能已经放置了方块,或者没有放置方块.每一轮,都会有一个新的由4个小方 ...

  10. CVE-2018-18955漏洞学习

    简介 这是名称空间的漏洞,文章先介绍user namespaces的简单只是,然后从补丁入手,分析源码,找到漏洞出现的原因.因为对这块的源码不是那么熟悉,所以着重描述源码分析的部分,其他可以参考末尾的 ...