Dubbo实战案例01【需求分析及项目创建】

文章目录

  • 一、案例介绍
    • 1.1 需求
    • 1.2 项目架构方式
    • 1.3 技术选型
  • 二、创建表
  • 三、项目设计
  • 四、创建项目
    • 1.创建dubbo-parent
      • 1.1 创建项目
      • 1.2 修改POM文件
    • 2.创建dubbo-pojo
      • 2.1 创建项目
      • 2.2 创建实体类
    • 3.创建dubbo-mapper
      • 3.1 创建项目
      • 3.2 创建UserMapper接口
      • 3.3 创建 UsersMapper 映射配置文件
      • 3.4 4修改 POM 文件
    • 4.创建服务提供者相关项目
      • 4.1创建dubbo-user-provider
        • 4.1.1 创建项目
      • 4.2创建dubbo-user-interface
        • 4.2.1 创建项目
        • 4.2.2 修改POM文件
      • 4.3创建dubbo-user-service
        • 4.3.1 创建项目
        • 4.3.2 修改POM文件
        • 4.3.3 配置MyBatis与Dubbo
          • db.properties
          • applicationContext-dao.xml
          • applicationContext-service.xml
          • applicationContext-trans.xml
          • SqlMapperClient.xml
          • application-dubbo.xml
        • 4.3.3 测试整合
    • 5.创建服务消费者相关项目
      • 5.1创建dubbo-user-consumer
        • 5.1.1 创建项目
      • 5.2创建dubbo-user-portal-service
        • 5.2.1 创建项目
        • 5.2.2 修改POM文件
      • 5.3创建dubbo-user-portal
        • 5.3.1 创建项目(war)
        • 5.3.2 修改POM文件
        • 5.3.3 配置 SpringMVC,Spring,web.xml,Dubbo
          • applicationContext-dubbo.xml
          • applicationContext-service.xml
          • springmvc.xml
          • web.xml
        • 5.3.4 测试整合

一、案例介绍

1.1 需求

  完成对用户表的CRUD操作。

1.2 项目架构方式

  SOA面向服务架构

1.3 技术选型

  maven,Spring,SpringMVC,Mybatis,Dubbo,Zookeeper,MySql

二、创建表

CREATE TABLE `users` (
 `userid` int(11) NOT NULL AUTO_INCREMENT,
 `username` varchar(30) DEFAULT NULL,
 `userage` int(11) DEFAULT NULL,
 PRIMARY KEY (`userid`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

三、项目设计

dubbo-parent (POM)
	|--dubbo-pojo (jar)
	|--dubbo-mapper (jar)
	|--dubbo-user-provider (POM)
		|--dubbo-user-provider-interface (jar)
		|--dubbo-user-provider-service  (jar)
	|--dubbo-user-consumer (pom)
		|--dubbo-user-consumer-portal-service  (jar)
		|--dubbo-user-consumer-protal (war)	

Dubbo实战案例01【需求分析及项目创建】_第1张图片

四、创建项目

1.创建dubbo-parent

1.1 创建项目

Dubbo实战案例01【需求分析及项目创建】_第2张图片

Dubbo实战案例01【需求分析及项目创建】_第3张图片

1.2 修改POM文件


	<properties>
		<junit.version>4.12junit.version>
		<spring.version>4.1.3.RELEASEspring.version>
		<mybatis.version>3.2.8mybatis.version>
		<mybatis.spring.version>1.2.2mybatis.spring.version>
		<mysql.version>5.1.32mysql.version>
		<slf4j.version>1.6.4slf4j.version>
		<druid.version>1.0.9druid.version>
		<jstl.version>1.2jstl.version>
		<servlet-api.version>2.5servlet-api.version>
		<tomcat.version>2.2tomcat.version>
		<jsp-api.version>2.0jsp-api.version>
		<zkClient-version>0.10zkClient-version>
		<dubbo-version>2.5.4dubbo-version>
	properties>


	
	<dependencyManagement>
		<dependencies>
			
			<dependency>
				<groupId>junitgroupId>
				<artifactId>junitartifactId>
				<version>${junit.version}version>
			dependency>
			
			<dependency>
				<groupId>org.slf4jgroupId>
				<artifactId>slf4j-log4j12artifactId>
				<version>${slf4j.version}version>
			dependency>
			
			<dependency>
				<groupId>org.mybatisgroupId>
				<artifactId>mybatisartifactId>
				<version>${mybatis.version}version>
			dependency>
			<dependency>
				<groupId>org.mybatisgroupId>
				<artifactId>mybatis-springartifactId>
				<version>${mybatis.spring.version}version>
			dependency>
			
			<dependency>
				<groupId>mysqlgroupId>
				<artifactId>mysql-connector-javaartifactId>
				<version>${mysql.version}version>
			dependency>
			
			<dependency>
				<groupId>com.alibabagroupId>
				<artifactId>druidartifactId>
				<version>${druid.version}version>
			dependency>
			
			<dependency>
				<groupId>org.springframeworkgroupId>
				<artifactId>spring-contextartifactId>
				<version>${spring.version}version>
			dependency>
			<dependency>
				<groupId>org.springframeworkgroupId>
				<artifactId>spring-beansartifactId>
				<version>${spring.version}version>
			dependency>
			<dependency>
				<groupId>org.springframeworkgroupId>
				<artifactId>spring-webmvcartifactId>
				<version>${spring.version}version>
			dependency>
			<dependency>
				<groupId>org.springframeworkgroupId>
				<artifactId>spring-jdbcartifactId>
				<version>${spring.version}version>
			dependency>
			<dependency>
				<groupId>org.springframeworkgroupId>
				<artifactId>spring-aspectsartifactId>
				<version>${spring.version}version>
			dependency>
			
			<dependency>
				<groupId>jstlgroupId>
				<artifactId>jstlartifactId>
				<version>${jstl.version}version>
			dependency>
			<dependency>
				<groupId>javax.servletgroupId>
				<artifactId>servlet-apiartifactId>
				<version>${servlet-api.version}version>
				<scope>providedscope>
			dependency>
			<dependency>
				<groupId>javax.servletgroupId>
				<artifactId>jsp-apiartifactId>
				<version>${jsp-api.version}version>
				<scope>providedscope>
			dependency>
			
			<dependency>
				<groupId>com.alibabagroupId>
				<artifactId>dubboartifactId>
				<version>${dubbo-version}version>
			dependency>
			<dependency>
				<groupId>com.101tecgroupId>
				<artifactId>zkclientartifactId>
				<version>${zkClient-version}version>
			dependency>
		dependencies>
	dependencyManagement>

	<build>
		<resources>
			<resource>
				<directory>src/main/javadirectory>
				<includes>
					<include>**/*.xmlinclude>
				includes>
			resource>
			<resource>
				<directory>src/main/resourcesdirectory>
				<includes>
					<include>**/*.xmlinclude>
					<include>**/*.propertiesinclude>
				includes>
			resource>
		resources>
		
		<pluginManagement>
			<plugins>
				
				<plugin>
					<groupId>org.apache.tomcat.mavengroupId>
					<artifactId>tomcat7-maven-pluginartifactId>
					<version>${tomcat.version}version>
				plugin>
			plugins>
		pluginManagement>
	build>

2.创建dubbo-pojo

2.1 创建项目

Dubbo实战案例01【需求分析及项目创建】_第4张图片

Dubbo实战案例01【需求分析及项目创建】_第5张图片

2.2 创建实体类

package com.bobo.pojo;

public class User {
	
	private int id;
	
	private String username;
	
	private int userage;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public int getUserage() {
		return userage;
	}

	public void setUserage(int userage) {
		this.userage = userage;
	}
}

Dubbo实战案例01【需求分析及项目创建】_第6张图片

3.创建dubbo-mapper

3.1 创建项目

Dubbo实战案例01【需求分析及项目创建】_第7张图片

3.2 创建UserMapper接口

package com.bobo.mapper;
/**
 * UsersMapper接口文件
 * @author dengp
 *
 */
public interface UsersMapper {

}

3.3 创建 UsersMapper 映射配置文件

<?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="com.bobo.mapper.UsersMapper">

</mapper>

3.4 4修改 POM 文件

<dependencies>
	<dependency>
		<groupId>com.bobogroupId>
		<artifactId>dubbo-pojoartifactId>
		<version>0.0.1-SNAPSHOTversion>
	dependency>
	
	<dependency>
		<groupId>org.mybatisgroupId>
		<artifactId>mybatisartifactId>
	dependency>
	<dependency>
		<groupId>org.mybatisgroupId>
		<artifactId>mybatis-springartifactId>
	dependency>
	
	<dependency>
		<groupId>mysqlgroupId>
		<artifactId>mysql-connector-javaartifactId>
	dependency>
	
	<dependency>
		<groupId>com.alibabagroupId>
		<artifactId>druidartifactId>
	dependency>
dependencies>
<build>
	<resources>
		<resource>
			<directory>src/main/javadirectory>
			<includes>
				<include>**/*.xmlinclude>
			includes>
		resource>
	resources>
build>

4.创建服务提供者相关项目

4.1创建dubbo-user-provider

4.1.1 创建项目

Dubbo实战案例01【需求分析及项目创建】_第8张图片

4.2创建dubbo-user-interface

4.2.1 创建项目

Dubbo实战案例01【需求分析及项目创建】_第9张图片

4.2.2 修改POM文件

<dependencies>
	
	<dependency>
		<groupId>com.bobogroupId>
		<artifactId>dubbo-pojoartifactId>
		<version>0.0.1-SNAPSHOTversion>
	dependency>
dependencies>

4.3创建dubbo-user-service

4.3.1 创建项目

Dubbo实战案例01【需求分析及项目创建】_第10张图片

4.3.2 修改POM文件

<dependencies>
	<dependency>
		<groupId>com.bobogroupId>
		<artifactId>dubbo-user-interfaceartifactId>
		<version>0.0.1-SNAPSHOTversion>
	dependency>

	<dependency>
		<groupId>com.bobogroupId>
		<artifactId>dubbo-mapperartifactId>
		<version>0.0.1-SNAPSHOTversion>
	dependency>

	<dependency>
		<groupId>com.alibabagroupId>
		<artifactId>dubboartifactId>
	dependency>

	<dependency>
		<groupId>com.101tecgroupId>
		<artifactId>zkclientartifactId>
	dependency>

	<dependency>
		<groupId>org.springframeworkgroupId>
		<artifactId>spring-jdbcartifactId>
	dependency>
	<dependency>
		<groupId>org.springframeworkgroupId>
		<artifactId>spring-aspectsartifactId>
	dependency>
dependencies>

4.3.3 配置MyBatis与Dubbo

db.properties
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssm?characterEncoding=utf-8
jdbc.username=root
jdbc.password=123456
applicationContext-dao.xml

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	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/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
	
    <context:property-placeholder location="classpath:db.properties"/>
	
	
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
	    <property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
		<property name="driverClassName" value="${jdbc.driver}" />
		<property name="maxActive" value="10" />
		<property name="minIdle" value="5" />
	bean>
	
	
	<bean class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource">
			<ref bean="dataSource"/>
		property>
		<property name="configLocation">
			<value>classpath:SqlMapperClient.xmlvalue>
		property>
	bean>
	
	
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.bobo.mapper"/>
	bean>
beans>
applicationContext-service.xml

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	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/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
	
	<context:component-scan base-package="com.bobo.dubbo.service.impl"/>
beans>
applicationContext-trans.xml

<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:aop="http://www.springframework.org/schema/aop" 
	xmlns:tx="http://www.springframework.org/schema/tx"
	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-4.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
    
   <bean id="transactionMananger" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"/>   
   bean>    
   
   
    <tx:advice id="advice" transaction-manager="transactionMananger">
   	<tx:attributes>
   		<tx:method name="add*" propagation="REQUIRED"/>
   		<tx:method name="modify*" propagation="REQUIRED"/>
   		<tx:method name="update*" propagation="REQUIRED"/>
   		<tx:method name="dorp*" propagation="REQUIRED"/>
   		<tx:method name="del*" propagation="REQUIRED"/>
   		<tx:method name="find*" read-only="true"/>
   	tx:attributes>
   tx:advice>
   
   
   <aop:config>
   	<aop:advisor advice-ref="advice" pointcut="execution(* com.bobo.dubbo.service.impl*.*(..))"/>
   aop:config>
beans>
SqlMapperClient.xml


<configuration>

configuration>
application-dubbo.xml

  服务提供者的配置文件我们放到META-INF/spring/目录下,我们通过main方法启动会自动加载该文件。
Dubbo实战案例01【需求分析及项目创建】_第11张图片


<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
	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://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
    
    
	<import resource="../../applicationContext-dao.xml" />
	<import resource="../../applicationContext-service.xml" />
	<import resource="../../applicationContext-trans.xml" />
	
	<dubbo:application name="user-provider" />
	<dubbo:registry protocol="zookeeper"
		address="192.168.88.171:2181,192.168.88.172:2181,192.168.88.173:2181"/>
		
	<dubbo:protocol name="dubbo" port="20880"/>
beans>

4.3.3 测试整合

package com.bobo;

import com.alibaba.dubbo.container.Main;

public class Start {

	/**
	 * 特点:
	 *	1,自带线程阻塞
	 *	2,支持优雅关系
	 *	Main 类下的 main 方法在启动时默认的回去 classpath:/META-INF/spring/*.xml
	 * @param args
	 */
	public static void main(String[] args) {
		Main.main(args);
	}
}

Dubbo实战案例01【需求分析及项目创建】_第12张图片

5.创建服务消费者相关项目

  创建消费者相关的服务。

5.1创建dubbo-user-consumer

5.1.1 创建项目

Dubbo实战案例01【需求分析及项目创建】_第13张图片

5.2创建dubbo-user-portal-service

5.2.1 创建项目

Dubbo实战案例01【需求分析及项目创建】_第14张图片

5.2.2 修改POM文件

<dependencies>
	<dependency>
		<groupId>com.bobogroupId>
		<artifactId>dubbo-user-interfaceartifactId>
		<version>0.0.1-SNAPSHOTversion>
	dependency>
	<dependency>
		<groupId>com.bobogroupId>
		<artifactId>dubbo-pojoartifactId>
		<version>0.0.1-SNAPSHOTversion>
	dependency>
	<dependency>
		<groupId>org.springframeworkgroupId>
		<artifactId>spring-contextartifactId>
	dependency>
	<dependency>
		<groupId>org.springframeworkgroupId>
		<artifactId>spring-beansartifactId>
	dependency>
dependencies>

5.3创建dubbo-user-portal

5.3.1 创建项目(war)

Dubbo实战案例01【需求分析及项目创建】_第15张图片

5.3.2 修改POM文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0modelVersion>
	<parent>
		<groupId>com.bobogroupId>
		<artifactId>dubbo-user-consumerartifactId>
		<version>0.0.1-SNAPSHOTversion>
	parent>
	<artifactId>dubbo-user-portalartifactId>
	<packaging>warpackaging>

	<dependencies>
		
		<dependency>
			<groupId>com.bobogroupId>
			<artifactId>dubbo-user-portal-serviceartifactId>
			<version>0.0.1-SNAPSHOTversion>
		dependency>
		<dependency>
			<groupId>junitgroupId>
			<artifactId>junitartifactId>
		dependency>
		
		<dependency>
			<groupId>org.slf4jgroupId>
			<artifactId>slf4j-log4j12artifactId>
		dependency>
		
		<dependency>
			<groupId>org.springframeworkgroupId>
			<artifactId>spring-webmvcartifactId>
		dependency>
		
		<dependency>
			<groupId>jstlgroupId>
			<artifactId>jstlartifactId>
		dependency>
		<dependency>
			<groupId>javax.servletgroupId>
			<artifactId>servlet-apiartifactId>
			<scope>providedscope>
		dependency>
		<dependency>
			<groupId>javax.servletgroupId>
			<artifactId>jsp-apiartifactId>
			<scope>providedscope>
		dependency>
		
		<dependency>
			<groupId>com.alibabagroupId>
			<artifactId>dubboartifactId>
		dependency>
		<dependency>
			<groupId>com.101tecgroupId>
			<artifactId>zkclientartifactId>
		dependency>
	dependencies>

	<build>
		<plugins>
			
			<plugin>
				<groupId>org.apache.tomcat.mavengroupId>
				<artifactId>tomcat7-maven-pluginartifactId>
				<configuration>
					
					<path>/path>
					<port>8082port>
				configuration>
			plugin>
		plugins>
	build>
project>

项目报错手动添加web.xml文件

Dubbo实战案例01【需求分析及项目创建】_第16张图片

5.3.3 配置 SpringMVC,Spring,web.xml,Dubbo

applicationContext-dubbo.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    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://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
        
 	<dubbo:application name="dubbo-consumer"/>
 	
 	<dubbo:registry  protocol="zookeeper"
 		address="192.168.88.171:2181,192.168.88.172:2181,192.168.88.173:2181" /> 

 beans>
applicationContext-service.xml

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	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/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
	
	<context:component-scan base-package="com.bobo.service"/>
beans>
springmvc.xml

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	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/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
	
	<context:component-scan base-package="com.bobo.controller" />

	
	<mvc:annotation-driven />

	
	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		
		<property name="prefix" value="/WEB-INF/jsp/" />
		<property name="suffix" value=".jsp" />
	bean>
	
	<mvc:resources location="/WEB-INF/css/" mapping="/css/**" />
	<mvc:resources location="/WEB-INF/js/" mapping="/js/**" />
beans>
web.xml

<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">
	
	<context-param>
		<param-name>contextConfigLocationparam-name>
		<param-value>classpath:applicationContext-*.xmlparam-value>
	context-param>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
	listener>

	
	<servlet>
		<servlet-name>springmvcservlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
		<init-param>
			<param-name>contextConfigLocationparam-name>
			<param-value>classpath:springmvc.xmlparam-value>
		init-param>
		<load-on-startup>1load-on-startup>
	servlet>
	<servlet-mapping>
		<servlet-name>springmvcservlet-name>
		<url-pattern>/url-pattern>
	servlet-mapping>

	<filter>
		<filter-name>encodingfilter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilterfilter-class>
		<init-param>
			<param-name>encodingparam-name>
			<param-value>utf-8param-value>
		init-param>
	filter>
	<filter-mapping>
		<filter-name>encodingfilter-name>
		<url-pattern>/*url-pattern>
	filter-mapping>


	<welcome-file-list>
		<welcome-file>index.htmlwelcome-file>
		<welcome-file>index.htmwelcome-file>
		<welcome-file>index.jspwelcome-file>
		<welcome-file>default.htmlwelcome-file>
		<welcome-file>default.htmwelcome-file>
		<welcome-file>default.jspwelcome-file>
	welcome-file-list>
web-app>

5.3.4 测试整合

Dubbo实战案例01【需求分析及项目创建】_第17张图片

访问测试: http://localhost:8082/index

Dubbo实战案例01【需求分析及项目创建】_第18张图片

能够访问说明整合成功~ 下篇介绍具体的业务实现

你可能感兴趣的:(dubbo,实战案例,dubbo专栏)