赞
踩
1:下载zookeeper ,稳定版3.4.8,最新版3.5.1,解压后,进入到conf目录,复制一份zoo_sample.conf,改名为zoo.conf,用无格式编辑器(比如sublime text,notepad等)打开,修改dataDir=/tmp/zookeeper
为你的动物园管理员数据存放路径,比如笔者的为D:/软件/ zookeeperData /动物园管理员,修改为dataDir=D:/software/zookeeperData/zookeeper
,保存即可,如果要配置ZK集群,还需要其他配置,暂时不说集群这一块,后面涉及到了再说。
zookeeper国内下载镜像地址:http ://mirrors.hust.edu.cn/apache/zookeeper/ bin /找到启动服务点击运行成功之后
2:下载JDK,maven安装配置这基础的东西就不说了找文档看看就会
3:dubbo-admin.war
这个战争包是阿里达博团队开发的一个可视化操作达博的后台管理服务,可是查看机器,提供者,消费者,以及手动配置负载权重等。将次包下载后,放在tomcat的的的webapps目录下,如果你的tomcat的和动物园管理员不是同一台服务器,需要修改战争包下的配置文件,将地址指向的动物园管理员的服务地址,端口是动物园管理员的端口,默认2181。
整体结构简单的分了一下,如下图所示:
1:新建项目
2;接着新建选中当前项目在当前项目下面接着新建模块soa-api
2.1:新建接口
的pom.xml
<?xml version =“1.0”?> <project xsi:schemaLocation =“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0。 xsd“ xmlns =”http://maven.apache.org/POM/4.0.0“xmlns:xsi =”http://www.w3.org/2001/XMLSchema-instance“> <modelVersion> 4.0.0 < / modelVersion> <parent> <groupId> cn.dubbo </ groupId> <artifactId> soa-dubbo </ artifactId> <version> 0.0.1-SNAPSHOT </ version> </ parent> <groupId> cn.dubbo.api </ groupId> <artifactId> dubbo-api </ artifactId> <name> dubbo-api </ name> <url> http://maven.apache.org </ url> <properties> <project.build.sourceEncoding> UTF-8 </project.build.sourceEncoding> </ properties> <dependencies> <dependency> <groupId> cn.dubbo.pojo </ groupId> <artifactId> dubbo-pojo </ artifactId> <version> 0.0.1- SNAPSHOT </ version> </ dependency> <dependency> <groupId> junit </ groupId> <artifactId> junit </ artifactId> <version> 3.8.1 </ version> <scope> test </ scope> </ dependency> </ dependencies> </ project>
继续新建pojo实体类模块核心工具类模块api-imp实现模块和上面新建api接口过程是一样的我就不截图了直接上代码
pojo模块
pom.xml
<?xml version =“1.0”?> <project xsi:schemaLocation =“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0。 xsd“ xmlns =”http://maven.apache.org/POM/4.0.0“xmlns:xsi =”http://www.w3.org/2001/XMLSchema-instance“> <modelVersion> 4.0.0 < / modelVersion> <parent> <groupId> cn.dubbo </ groupId> <artifactId> soa-dubbo </ artifactId> <version> 0.0.1-SNAPSHOT </ version> </ parent> <groupId> cn.dubbo.pojo </ groupId> <artifactId> dubbo-pojo </ artifactId> <name> dubbo-pojo </ name> <url> http://maven.apache.org </ url> <properties> <project.build.sourceEncoding> UTF-8 </project.build.sourceEncoding> </ properties> <dependencies> <dependency> <groupId> junit </ groupId> <artifactId> junit </ artifactId> <version> 3.8.1 </ version> <scope> </ scope> </ dependency> </ dependencies> </ project>
core模块
pom.xml
<?xml version =“1.0”?> <project xsi:schemaLocation =“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0。 xsd“ xmlns =”http://maven.apache.org/POM/4.0.0“xmlns:xsi =”http://www.w3.org/2001/XMLSchema-instance“> <modelVersion> 4.0.0 < / modelVersion> <parent> <groupId> cn.dubbo </ groupId> <artifactId> soa-dubbo </ artifactId> <version> 0.0.1-SNAPSHOT </ version> </ parent> <groupId> cn.dubbo.core </ groupId> <artifactId> dubbo-core </ artifactId> <name> dubbo-core </ name> <url> http://maven.apache.org </ url> <properties> <project.build.sourceEncoding> UTF-8 </project.build.sourceEncoding> <spring.version> 4.1.4.RELEASE </spring.version> <spring-ck.version> 3.0.5.RELEASE </spring-ck.version> <jackson。版本> 2.5.0 </jackson.version> </ properties> <dependencies> <dependency> <groupId> junit </ groupId> <artifactId> junit </ artifactId> <version> 3.8.1 </ version> <scope>测试</ scope> </ dependency> <! - spring - > <dependency> <groupId> org.springframework </ groupId> <artifactId> spring-web </ artifactId> <version> $ { pring-ck.version} </ version> </ dependency> <dependency> <groupId> org.springframework </ groupId> <artifactId> spring-webmvc </ artifactId> <version> $ {spring-ck.version}版本> </依赖性> <依赖性> <的groupId> org.springframework </的groupId> <artifactId的>弹簧OXM </ artifactId的> <版本> $ {弹簧ck.version} </版本> </依赖性> <依赖性> <groupId> org.springframework </ groupId> <artifactId> spring-orm </ artifactId> <version> $ {spring-ck.version} </ version> </ dependency> <dependency> <groupId> org.springframework < / groupId> <artifactId> spring-jdbc </ artifactId> <version> $ {spring.version} </ version> </ dependency> <dependency> <groupId> org.springframework </ groupId> <artifactId> spring-test < /的artifactId> <版本> $ {spring.version} </版本> <范围>测试</范围> </依赖性> <依赖性> <的groupId> com.alibaba </的groupId> <artifactId的>多宝</ artifactId的> <版本> 2.5.3 </ version> <排除> <排除> <artifactId> spring </ artifactId> <groupId> org.springframework </ groupId> </排除> </排除> </ depe ndency> <dependency> <groupId> org.apache.zookeeper </ groupId> <artifactId> zookeeper </ artifactId> <version> 3.4.6 </ version> </ dependency> <dependency> <groupId> com.netflix.curator </的groupId> <artifactId的>馆长的框架</ artifactId的> <版本> 1.1.10 </版本> </依赖性> <依赖性> <的groupId> com.101tec </的groupId> <artifactId的> zkclient </ artifactId的> <版本> 0.6 </ version> </ dependency> <dependency> <groupId> javax.servlet </ groupId> <artifactId> jstl </ artifactId> <version> 1.2 </ version> </ dependency> <! - mybatis - > <dependency> <groupId> org.mybatis </ groupId> <artifactId> mybatis </ artifactId> <version> 3.2.8 </ version> </ dependency> <! - mybatis spring插件 - > <dependency > <groupId> org.mybatis </ groupId> <artifactId> mybatis-spring </ artifactId> <version> 1.2.2 </ version> </ dependency> <! - mysql连接 - > <dependency> <groupId> mysql </ groupId> <artifactId> mysql-connector-java </ artifactId> <version> 5.1.34 </ version> </ dependency> <! - 数据源 - > <dependency> <groupId> com.alibaba < / groupId> <arti factId> druid </ artifactId> <version> 1.0.12 </ version> </ dependency> <dependency> <groupId> org.aspectj </ groupId> <artifactId> aspectjweaver </ artifactId> <version>版本> </ dependency> <! - json - > <dependency> <groupId> org.codehaus.jackson </ groupId> <artifactId> jackson-mapper-asl </ artifactId> <version> 1.9.13 </ version > </ dependency> < dependency> <dependencyId> com.alibaba </ groupId> <artifactId> fastjson </ artifactId> <version> 1.2.3 </ version> </ dependency> <dependency> <groupId> com.fasterxml。 jackson.core </ groupId> <artifactId> jackson-annotations </ artifactId> <version> $ {jackson.version} </ version> </ dependency> <dependency> <groupId> com.fasterxml.jackson.core </ groupId > <artifactId> jackson-core </ artifactId> <version> $ {jackson.version} </ version> </ dependency> <dependency> <groupId> com.fasterxml.jackson.core </ groupId> <artifactId> jackson- databind </ artifactId> <version> $ {jackson.version} </ version> </ dependency> <! - 文件上传 - > <dependency> <groupId> commons-io </ groupId> <artifactId> commons-i o </ artifactId> <version> 2.4 </ version> </ dependency> <dependency> <groupId> commons-fileupload </ groupId> <artifactId> commons-fileupload </ artifactId> <version> 1.2.2 </ version> </ dependency> <! - servlet - > <dependency> <groupId> javax.servlet </ groupId> <artifactId> javax.servlet-api </ artifactId> <version> 3.0.1 </ version> </ dependency > </ dependencies> </ project>
api-imp模块
UserserviceImp
DubboMain
包org.dubbo.api.imp; import org.dubbo.api.dao.UserMapper; import org.dubbo.api.service.UserService; import org.dubbo.pojo.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service(“userService”) public class UserServiceImp实现UserService { @Autowired UserMapper userMapper; public User findById(int id){ User us = userMapper.findById(1); 回归我们 } }
package org.dubbo.api.main; import java.io.IOException; import org.springframework.context.support.ClassPathXmlApplicationContext; public class DubboMain { public static void main(String [] args)throws IOException { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String [] {“dubbo.xml”}); context.start(); System.in.read(); //按任意键退出 // Main.main(args); } }
log4j的
### set log levels ### log4j.rootLogger = INFO,C,D,E ### console ### log4j.appender.C = org.apache.log4j.ConsoleAppender log4j.appender.C.Target = System。 out log4j.appender.C.layout = org.apache.log4j.PatternLayout log4j.appender.C.layout.ConversionPattern = [%p] [%-d {yyyy-MM-dd HH:mm:ss}]%C。 %M(%L)| %m%n ### log file ### log4j.appender.D = org.apache.log4j.DailyRollingFileAppender log4j.appender.D.File = ../logs/ServerManager-Info.log log4j.appender.D.Append = true log4j.appender.D.Threshold = INFO log4j.appender.D.layout = org.apache.log4j.PatternLayout log4j.appender.D.layout.ConversionPattern = [%p] [%-d {yyyy-MM-dd HH:mm:ss}]%C.%M(%L)| %m%n ### exception ### log4j.appender.E = org.apache.log4j.DailyRollingFileAppender log4j.appender.E.File = ../logs/ServerManager-Error.log log4j.appender.E.Append = true log4j.appender.E.Threshold = ERROR log4j.appender.E.layout = org.apache.log4j.PatternLayout log4j.appender.E.layout.ConversionPattern = [%p] [%-d {yyyy-MM-dd HH :mm:ss}]%C.%M(%L)| %米%正
dubbo.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 =“dubbo_provider”/> <! - 使用zookeeper注册中心暴露服务地址 - > <dubbo:registry address =“127.0.0.1:2181” protocol =“zookeeper”/> <! - 用dubbo协议在20880端口暴露服务 - > <dubbo:protocol name =“dubbo”port =“20880”/> <! - 声明需要暴露的服务接口 - > <dubbo:service interface =“org.dubbo.api.service.UserService”ref =“userService”/> <bean id =“userService”class =“org.dubbo.api.imp.UserServiceImp”> </ bean> <import resource =“classpath *:applicationMybatis.xml”/> </ bea NS>
db
driverClassName = com.mysql.jdbc.Driver url = jdbc:mysql:// localhost:3306 / wb ?? useUnicode = true&characterEncoding = UTF-8 username = root password = 1234 c3p0.pool.size.max = 20 c3p0.pool。 size.min = 5 c3p0.pool.size.ini = 3 c3p0.pool.size.increment = 2
applicationMabatis
<?xml version =“1.0”encoding =“UTF-8”?> <beans xmlns =“http://www.springframework.org/schema/beans”xmlns:mvc =“http://www.springframework.org / schema / mvc“ xmlns:xsi =”http://www.w3.org/2001/XMLSchema-instance“xmlns:aop =”http://www.springframework.org/schema/aop“ xmlns:tx =” http://www.springframework.org/schema/tx“xmlns:context =”http://www.springframework.org/schema/context“ xsi:schemaLocation =” http://www.springframework.org/schema/ beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc .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 *:db.properties” /> <! - 数据源,使用dbcp - > <bean id =“dataSource”class =“com.alibaba.druid.pool.DruidDataSource”destroy-method =“close”> <property name =“driverClassName” =“$ {driverClassName}”/> <property name =“url”value =“$ {url}”/> <property name =“username”value =“$ {username}”/> <property name =“password” value =“$ {password}”/> <! - <property name =“maxPoolSize”value =“$ {c3p0.pool.size.max}”/> <property name =“minPoolSize”value =“$ {c3p0 .pool.size.min}“ /> <property name =”initialPoolSize“value =”$ {c3p0.pool.size.ini}“/> <property name =”acquireIncrement“ value =”$ {c3p0.pool.size .increment}“/> - > </ bean> <! - sqlSessionFactory - > <bean id =”sqlSessionFactory“class =”org.mybatis.spring.SqlSessionFactoryBean“> <! - 加载mybatis的配置文件 - - > <属性名= “typeAliasesPackage”值= “org.dubbo.pojo”> </属性> <属性名= “mapperLocations”值= “类路径:组织/多宝/ API /刀/ * XML”/> < ! -数据源- > <属性名= “数据源” REF = “数据源”/> </豆> <! -映射器批量扫描 从映射器包中扫描出映射器接口,自动创建代理对象并且在弹簧容器中注册- > <! -自动扫描出来的映射器的豆的ID为映射器类名(首字母小写) - > <! - - 扫描多个包用,分开 - > <bean class =“org.mybatis.spring.mapper.MapperScannerConfigurer”> <property name =“basePackage”value =“org.dubbo.api.dao”/> <property name =“sqlSessionFactoryBeanName”value =“sqlSessionFactory”/> </ bean> <! - 事物管理器对于mybatis操作数据库事物控制,spring使用Jdbc的事物控制类 - > <bean id =“transactionManager”class =“org .springframework.jdbc.datasource.DataSourceTransactionManager“> <! - 数据源dataSource在applicationContext-dao.xml中配置了 - > <property name =”dataSource“ref =”dataSource“> </ property> </ bean> <! - 通知 - > <tx:advice id =“txAdvice”transaction-manager =“transactionManager”> <tx:attributes> <! - 传播行为 - > <tx:method name =“save *” =“REQUIRED”/> <tx:method name =“add *”propagation =“REQUIRED”/> <tx:method name =“ insert *“propagation =”REQUIRED“/> <tx:method name =”update *“propagation =”REQUIRED“/> <tx:method name =”delete *“propagation =”REQUIRED“/> <tx:method name = “找到*”传播= “支撑件”只读= “真”/> <TX:方法名= “*”传播= “支撑件”只读= “真”/> </ TX:属性> </ TX :advice> <! - aop - > <aop:config> <aop:advisor advice-ref =“txAdvice”pointcut =“execution(* org.dubbo.api.imp .. *。*(..)) “/> </ aop:config> </ beans>
好到这里该去试下dubbo和zoopeeker通不通了找到DubooMain类运行主方法控制台没报错说明已经成功
相应zoopeeper命令行也会有动荡下面开始整合springmvc + mybatis
找到新建的api-imp模块
新建dao 包
还有对应的xml你可以自动生成也可以手动写我这里手动写了UserMapper.xml
<?xml version =“1.0”encoding =“UTF-8”?> <!DOCTYPE mapper PUBLIC“ - // mybatis.org//DTD Mapper 3.0 // EN” “http://mybatis.org/dtd/mybatis -3-mapper.dtd“> <mapper namespace =”org.dubbo.api.dao.UserMapper“> <resultMap id =”user“type =”org.dubbo.pojo.User“> <id column =”userid“ property =“userid”/> <result column =“name”property =“name”/> </ resultMap> <select id =“findById”parameterType =“int”resultType =“user”> select * from user where userid = #{id} </ select> </ mapper>
添加完成之后在运行一下刚刚的main方法看报不报错不报错那就问题不大了继续往下新建一个模块控制层soa-action
\
这里有报错不要管它不影响使用编译的问题
UserAction
包org.dubbo.action; import javax.servlet.http.HttpServletRequest; import org.dubbo.api.service.UserService; import org.dubbo.pojo.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller @Scope(“prototype”)@ RequestMapping( value =“/ wx”) public class UserAction { @Autowired public UserService userService; @RequestMapping(value =“/ listUser”,method = RequestMethod.GET) public void listUser(HttpServletRequest request){ User u = userService.findById(1); 通信System.err.println(u.getName()); } }
dubbo_action
<?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 =“consumer-of-helloworld-app”/> - > <!使用组播广播注册中心暴露发现服务地址 - > <! - <dubbo:registry address =“multicast://224.5.6.7:1234”/> - > <! - 公共信息,也可以用dubbo。属性配置 - > <dubbo:application name =“annotation-consumer”/> <dubbo:registry address =“127.0.0.1:2181”protocol =“zookeeper”/> <! - 扫描注解包路径,多个包用逗号分隔,不填pacakge表示扫描当前的ApplicationContext 中所有的类 - > <! - <dubbo:annotation package =“com.alibaba.dubbo.demo”/> - > <! - 生成远程服务代理,可以和本地bean一样使用demoService - > <dubbo:reference id =“userService”interface =“org.dubbo.api.service.UserService”/> <! - 声明需要引用的服务接口 - > </ beans>
log4j直接复制上面api-imp接口实现的用SpringMVC
<?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:mvc =”http://www.springframework.org/schema/mvc“xmlns:context =”http://www.springframework.org/schema/context“ xmlns:aop =” http://www.springframework.org/schema/aop“xmlns:tx =”http://www.springframework.org/schema/tx“ xsi:schemaLocation =”http://www.springframework.org/schema/豆 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring -mvc-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/ schema / aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx /spring-tx-3.0.xsd“> <context:annotation-config /> <context:component-scan base-package =”org.d ubbo.action“> <context:include-filter type =”annotation“expression =”org.springframework.stereotype.Controller“/> </ context:component-scan> <bean class =”org.springframework.web.servlet。 mvc.annotation.AnnotationMethodHandlerAdapter“/> <bean class =”org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping“/> <! - 静态资源的访问 - > <! - 视图分解器 - > <bean id =“viewResolver”class =“org.springframework.web.servlet.view.InternalResourceViewResolver”> <property name =“prefix”value =“/”/> <property name =“suffix”value =“。jsp” /> </ bean> <! - 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) - > <bean id =“messageSource”class =“org.springframework.context.support。 ReloadableResourceBundleMessageSource “> <属性名=”基本名称“> <列表> < -在网络环境中一定要定位到classpath中否则默认到当前的Web应用下找- >! <值>类路径:/邮件</值> < / list> </ property> <property name =“useCodeAsDefaultMessage”value = “false”/> <property name =“defaultEncoding”value =“UTF-8”/> <property name =“cacheSeconds”value =“60”/> </ bean> <! - 避免IE在ajax请求时,返回json发现下载 - > <bean id =“jacksonMessageConverter”class =“org.springframework.http.converter.json.MappingJacksonHttpMessageConverter”> <property name =“supportedMediaTypes”> <list> <value> text / html; charset = UTF-8 </ value> </ list> </ property> </ bean> <! - 上传文件的解析器 - > <bean id =“multipartResolver”class =“org.springframework.web.multipart.commons .CommonsMultipartResolver “> <属性名=” defaultEncoding”值= “UTF-8”/> <属性名= “maxUploadSize”值= “10485760000”/> <属性名= “maxInMemorySize”值= “40960”/> </ bean> <import resource =“classpath:dubbo_action.xml”/> </ beans>
POMweb.xml中
<?xml version =“1.0”?> <project xsi:schemaLocation =“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0。 xsd“ xmlns =”http://maven.apache.org/POM/4.0.0“xmlns:xsi =”http://www.w3.org/2001/XMLSchema-instance“> <modelVersion> 4.0.0 < / modelVersion> <parent> <groupId> cn.dubbo </ groupId> <artifactId> soa-dubbo </ artifactId> <version> 0.0.1-SNAPSHOT </ version> </ parent> <artifactId> dubbo-action < artifactId> <packaging> war </ package > <name> dubbo-action Maven Webapp </ name> <url> http://maven.apache.org </ url> <dependencies> <dependency> <groupId> cn.dubbo .pojo </ groupId> <artifactId> dubbo-pojo </ artifactId> <version> 0.0.1-SNAPSHOT </ version> </ dependency> <dependency> <groupId> cn.dubbo.api </ groupId> <artifactId> dubbo-api </ artifactId> <version> 0.0.1-SNAPSHOT </ version> </ dependency> <dependency> <groupId> cn.dubbo.core </ groupId> <artifactId> dubbo-core </ artifactId> <version > 0.0.1-SNAPSHOT </ version> </ dependency> <dependency> <groupId> junit </ groupId> <artifactId> junit </ artifactId> <version> 4。12 </ version> <scope> test </ scope> </ dependency> </ dependencies> <build> <finalName> dubbo-action </ finalName> </ build> </ project>
xmlns =“1.0”encoding =“UTF-8”?< http://www.w3.org/2001/XMLSchema-instance“xsi:schemaLocation =”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/的JavaEE /网络app_2_5.xsd“> 的<servlet> <servlet的名称>用SpringMVC </ servlet的名称> <servlet的类> org.springframework.web.servlet.DispatcherServlet </ servlet的类> <INIT-PARAM> < param-name> contextConfigLocation </ param-name> <param-value> classpath *:springmvc.xml </ param-value> </ init-param> <load-on-startup> 1 </ load-on-startup> </ servlet> <servlet-mapping> <servlet-name> springmvc </ servlet-name> <url-pattern> * 。do < / url-pattern> </ servlet-mapping> <filter> <filter-name> SpringEncodingFilter </ 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> <init-param> <param-name> forceEncoding </ param-name> <param-value> true </ param-value> </ ini t-param> </ filter> <filter-mapping> <filter-name> SpringEncodingFilter </ filter-name> <url-pattern> / * </ url-pattern> </ filter-mapping> <welcome-file-list > <welcome-file> login.jsp </ welcome-file> </ welcome-file-list> </ web-app>
好到这里就完事了检查一下代码如果没有问题启动zoopeeker启动api-imp里面的main方法然后tomcat启动当前的这个web程序 打开浏览器请求这个地址然后返回去看IDE输出的数据
如果有打印说明基本配置已完成
如果上述看的不是很明白这里有写好能运行的源代码
http://download.csdn.net/download/wangbo54979/9934692
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。