标签:dubbo+zookeeper dubbo分布式服务 dubbo+springmvc+mybatis redis分布式缓存 maven+springmvc
所有配置文件在此
spring servlet:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd 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/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <aop:aspectj-autoproxy proxy-target-class="true"/> <aop:config proxy-target-class="true"/> <!-- 会自动注册DefaultAnnotationHandlerMapping与AnnotationMethodHandlerAdapter 两个bean,是spring MVC为@Controllers分发请求所必须的 --> <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"> <mvc:message-converters register-defaults="true"> <!-- 将StringHttpMessageConverter的默认编码设为UTF-8 --> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <constructor-arg name="defaultCharset" value="UTF-8"/> </bean> <!-- 将Jackson2HttpMessageConverter的默认格式化输出设为true --> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="prettyPrint" value="true"/> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven> <!-- REST中根据URL后缀自动判定Content-Type及相应的View --> <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> <property name="ignoreAcceptHeader" value="true"/> <property name="defaultContentType" value="text/html"/> <property name="mediaTypes"> <value> json=application/json xml=application/xml </value> </property> </bean> <!-- 支持返回json --> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html; charset=utf-8</value> </list> </property> </bean> <bean class="org.springframework.http.converter.ResourceHttpMessageConverter"/> <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/> <bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"/> </list> </property> </bean> <!-- 扫描service(自动将servicec层注入) --> <context:component-scan base-package="com.focustech.micen"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/> </context:component-scan> <!-- 以下 validator ConversionService 在使用 mvc:annotation-driven 会自动注册 --> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> <property name="providerClass" value="org.hibernate.validator.HibernateValidator"/> <!-- 如果不加默认到 使用classpath下的 ValidationMessages.properties --> <property name="validationMessageSource" ref="messageSource"/> </bean> <!-- 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) --> <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource" p:basename="i18n/messages/"/> <!-- Maps ‘/‘ requests to the ‘home‘ view --> <mvc:view-controller path="/" view-name="/login"/> <!-- resources,js,css可多选 --> <mvc:resources location="/assets/" mapping="/assets/**"/> <!-- 配置springMVC处理上传文件的信息 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" p:defaultEncoding="utf-8" p:maxUploadSize="10485760000" p:maxInMemorySize="40960"/> <bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape"/> <!-- FreeMarker视图解析 --> <bean id="freeMarkerViewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver" p:prefix="/" p:suffix=".ftl" p:order="1" p:cache="true"> <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/> <property name="contentType" value="text/html;charset=utf-8"/> <property name="requestContextAttribute" value="request"/> <property name="exposeRequestAttributes" value="true"/> <property name="exposeSessionAttributes" value="true"/> <property name="exposeSpringMacroHelpers" value="true"/> <!-- <property name="viewNames"> <array> <value>*.ftl</value> </array> </property> --> </bean> <!--<bean id="freemarkConfig" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="location" value="classpath:properties/freemark.properties"/> </bean>--> <!-- FreeMarker环境配置 --> <!-- <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> --> <bean id="freemarkerConfig" class="com.focustech.micen.common.support.ShiroTagFreeMarkerConfigurer"> <!-- freemarker模板位置 --> <property name="templateLoaderPath" value="/views/"/> <property name="defaultEncoding" value="utf-8"/> <property name="freemarkerVariables"> <map> <entry key="xml_escape" value-ref="fmXmlEscape"/> </map> </property> <property name="freemarkerSettings"> <props> <prop key="template_update_delay">5</prop> <!--刷新模板的周期,单位为秒,开发环境中可以设置短一点,正式环境可以长一点 --> <prop key="defaultEncoding">UTF-8</prop> <prop key="url_escaping_charset">UTF-8</prop> <prop key="locale">zh_CN</prop> <prop key="boolean_format">true,false</prop> <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop> <prop key="date_format">yyyy-MM-dd</prop> <prop key="time_format">HH:mm:ss</prop> <prop key="number_format">#.##</prop> <prop key="whitespace_stripping">true</prop> <prop key="tag_syntax">auto_detect</prop> <prop key="url_escaping_charset">UTF-8</prop> <prop key="template_exception_handler">ignore</prop> <prop key="classic_compatible">true</prop> <!-- auto_import可导入多个文件, 用逗号分开 --> <!--<prop key="auto_import">views/common/*.ftl</prop>--> </props> </property> </bean> <!-- jsp视图解析器 --> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:order="2" p:prefix="/" p:suffix=".jsp" p:viewClass="org.springframework.web.servlet.view.JstlView"/> <!-- 全局异常配置 start --> <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <prop key="java.lang.Exception">error-500</prop> <prop key="java.lang.Throwable">error-404</prop> <prop key="java.sql.SQLException">error-403</prop> <prop key="org.springframework.web.servlet.PageNotFound">error-404</prop> <prop key="org.apache.shiro.ShiroException">error-auth</prop> <prop key="com.focustech.micen.common.exception.AccessException">error-data</prop> </props> </property> <property name="statusCodes"> <props> <prop key="error-404">404</prop> <prop key="error-403">403</prop> <prop key="error-500">500</prop> <prop key="error-auth">505</prop> <prop key="error-data">506</prop> </props> </property> <!-- 设置日志输出级别,不定义则默认不输出警告等错误日志信息 --> <property name="warnLogCategory" value="WARN"></property> <!-- 默认错误页面,当找不到上面mappings中指定的异常对应视图时,使用本默认配置 --> <property name="defaultErrorView" value="error-405"></property> <!-- 默认HTTP状态码 --> <property name="defaultStatusCode" value="500"></property> </bean>
</beans>
spring context:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" 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/aop http://www.springframework.org/schema/aop/spring-aop.xsd" default-lazy-init="true"> <!-- 启用shrio授权注解拦截方式 --> <aop:config proxy-target-class="true"></aop:config> <!-- 扫描service(自动将servicec层注入) --> <context:component-scan base-package="com.focustech.micen"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/> <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan> <import resource="spring-datasource.xml"/> <import resource="spring-captcha.xml"/> <import resource="spring-shiro.xml"/></beans>
spring capche:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" 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" default-lazy-init="true"> <bean id="captchaService" class="com.octo.captcha.service.multitype.GenericManageableCaptchaService"> <constructor-arg index="0" ref="imageEngine"/> <constructor-arg type="int" index="1" value="180"/> <constructor-arg type="int" index="2" value="100000"/> </bean> <bean id="imageEngine" class="com.octo.captcha.engine.GenericCaptchaEngine"> <constructor-arg index="0"> <list> <ref bean="captchaFactory"/> </list> </constructor-arg> </bean> <bean id="captchaFactory" class="com.octo.captcha.image.gimpy.GimpyFactory"> <constructor-arg ref="wordgen"/> <constructor-arg ref="wordtoimage"/> </bean> <!--可选字符--> <bean id="wordgen" class="com.octo.captcha.component.word.wordgenerator.RandomWordGenerator"> <constructor-arg value="0123456789abcdefghijklmnopqrstuvwxyz"/> </bean> <bean id="wordtoimage" class="com.octo.captcha.component.image.wordtoimage.ComposedWordToImage"> <constructor-arg index="0" ref="fontGenRandom"/> <constructor-arg index="1" ref="backGenUni"/> <constructor-arg index="2" ref="decoratedPaster"/> </bean> <bean id="fontGenRandom" class="com.octo.captcha.component.image.fontgenerator.RandomFontGenerator"> <!--最小字体--> <constructor-arg index="0" value="20"/> <!--最大字体--> <constructor-arg index="1" value="20"/> <!--字体--> <constructor-arg index="2"> <list> <bean class="java.awt.Font"> <constructor-arg index="0" value="Arial"/> <constructor-arg index="1" value="0"/> <constructor-arg index="2" value="20"/> </bean> </list> </constructor-arg> </bean> <bean id="backGenUni" class="com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator"> <!--背景宽度--> <constructor-arg index="0" value="82"/> <!--背景高度--> <constructor-arg index="1" value="32"/> </bean> <bean id="decoratedPaster" class="com.octo.captcha.component.image.textpaster.DecoratedRandomTextPaster"> <!--最大字符长度--> <constructor-arg type="java.lang.Integer" index="0" value="5"/> <!--最小字符长度--> <constructor-arg type="java.lang.Integer" index="1" value="5"/> <!--文本颜色--> <constructor-arg index="2" ref="colorGen"/> <!--文本混淆--> <constructor-arg index="3"> <list> <ref bean="baffleDecorator"/> </list> </constructor-arg> </bean> <bean id="baffleDecorator" class="com.octo.captcha.component.image.textpaster.textdecorator.BaffleTextDecorator"> <constructor-arg type="java.lang.Integer" index="0" value="0"/> <constructor-arg type="java.awt.Color" index="1" ref="colorWrite"/> </bean> <bean id="colorGen" class="com.octo.captcha.component.image.color.SingleColorGenerator"> <constructor-arg type="java.awt.Color" index="0" ref="colorDimGrey"/> </bean> <bean id="colorWrite" class="java.awt.Color"> <constructor-arg type="int" index="0" value="255"/> <constructor-arg type="int" index="1" value="255"/> <constructor-arg type="int" index="2" value="255"/> </bean> <bean id="colorDimGrey" class="java.awt.Color"> <constructor-arg type="int" index="0" value="0"/> <constructor-arg type="int" index="1" value="102"/> <constructor-arg type="int" index="2" value="204"/> </bean></beans>
核心技术:Maven,Springmvc mybatis shiro, Druid, Restful,
Dubbo, ZooKeeper,Redis,FastDFS,ActiveMQ,Nginx
1. 项目核心代码结构截图
项目模块依赖
特别提醒:开发人员在开发的时候可以将自己的业务REST服务化或者Dubbo服务化
2. 项目依赖介绍
2.1 后台管理系统、Rest服务系统、Scheculer定时调度系统依赖如下图:
2.2 Dubbo独立服务项目依赖如下图:
3. 项目功能部分截图:
zookeeper、dubbo服务启动
dubbo管控台
REST服务平台
Spring+mybatis+shiro+freemarker+ehcache+ldap+mongo【转】
标签:dubbo+zookeeper dubbo分布式服务 dubbo+springmvc+mybatis redis分布式缓存 maven+springmvc
原文地址:http://11936510.blog.51cto.com/11926510/1860787