Dubbo+Zookeeper分布式部署

本文详细介绍了如何使用Dubbo结合Zookeeper进行分布式部署。内容涵盖消费端的controller和服务层,以及生产端的服务实现和数据访问层。重点讨论了两端的bean配置,特别是消费端的service接口和生产端的serviceImpl实现,同时提到了配置文件XML的差异。
摘要由CSDN通过智能技术生成

消费端:controller/service

生产端:ServiceImpl/Mapper(Dao)


主要是注意两端层级结构,两边都要有bean,消费端service接口,生产端seviceImpl,其次就是配置文件的xml的区别


生产端:Bean

package com.jk.provide.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class TAtyUser  implements Serializable{
    /**
	 * 
	 */
	private static final long serialVersionUID = 8526726857563431642L;

	private String cId;

    private String cLoginid;

    private String cName;

    private String cPassword;

    private String cMail;

    private String cIp;

    private String cXmjp;

    private String cCorp;

    private String cDept;

    private Integer nValid;

    private Short nOrder;

    private String usercode;

    private String userpost;

    private String cZw;

    private String cLinkuser;

    private Integer nRylx;

    private Integer nShowUser;

    private Integer nTxl;

    private Integer nSfkq;
    
    private String authImage;

    public String getcId() {
        return cId;
    }

    public void setcId(String cId) {
        this.cId = cId == null ? null : cId.trim();
    }

    public String getAuthImage() {
		return authImage;
	}

	public void setAuthImage(String authImage) {
		this.authImage = authImage;
	}

	public String getcLoginid() {
        return cLoginid;
    }

    public void setcLoginid(String cLoginid) {
        this.cLoginid = cLoginid == null ? null : cLoginid.trim();
    }

    public String getcName() {
        return cName;
    }

    public void setcName(String cName) {
        this.cName = cName == null ? null : cName.trim();
    }

    public String getcPassword() {
        return cPassword;
    }

    public void setcPassword(String cPassword) {
        this.cPassword = cPassword == null ? null : cPassword.trim();
    }

    public String getcMail() {
        return cMail;
    }

    public void setcMail(String cMail) {
        this.cMail = cMail == null ? null : cMail.trim();
    }

    public String getcIp() {
        return cIp;
    }

    public void setcIp(String cIp) {
        this.cIp = cIp == null ? null : cIp.trim();
    }

    public String getcXmjp() {
        return cXmjp;
    }

    public void setcXmjp(String cXmjp) {
        this.cXmjp = cXmjp == null ? null : cXmjp.trim();
    }

    public String getcCorp() {
        return cCorp;
    }

    public void setcCorp(String cCorp) {
        this.cCorp = cCorp == null ? null : cCorp.trim();
    }

    public String getcDept() {
        return cDept;
    }

    public void setcDept(String cDept) {
        this.cDept = cDept == null ? null : cDept.trim();
    }

  

    public Short getnOrder() {
        return nOrder;
    }

    public void setnOrder(Short nOrder) {
        this.nOrder = nOrder;
    }

    public String getUsercode() {
        return usercode;
    }

    public void setUsercode(String usercode) {
        this.usercode = usercode == null ? null : usercode.trim();
    }

    public String getUserpost() {
        return userpost;
    }

    public void setUserpost(String userpost) {
        this.userpost = userpost == null ? null : userpost.trim();
    }

    public String getcZw() {
        return cZw;
    }

    public void setcZw(String cZw) {
        this.cZw = cZw == null ? null : cZw.trim();
    }

    public String getcLinkuser() {
        return cLinkuser;
    }

    public void setcLinkuser(String cLinkuser) {
        this.cLinkuser = cLinkuser == null ? null : cLinkuser.trim();
    }

    public Integer getnRylx() {
        return nRylx;
    }

    public void setnRylx(Integer nRylx) {
        this.nRylx = nRylx;
    }

   
    public Integer getnTxl() {
        return nTxl;
    }

    public void setnTxl(Integer nTxl) {
        this.nTxl = nTxl;
    }

	public Integer getnValid() {
		return nValid;
	}

	public void setnValid(Integer nValid) {
		this.nValid = nValid;
	}

	public Integer getnShowUser() {
		return nShowUser;
	}

	public void setnShowUser(Integer nShowUser) {
		this.nShowUser = nShowUser;
	}

	public Integer getnSfkq() {
		return nSfkq;
	}

	public void setnSfkq(Integer nSfkq) {
		this.nSfkq = nSfkq;
	}

   
}

生产端:Mapper

package com.jk.provide.mapper.dao;

import java.util.List;

import com.jk.provide.bean.TAtyUser;



public interface TAtyUserMapper {
    
    List<TAtyUser> getAllUserList();

}

生产端:Mapper.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="com.jk.provide.mapper.dao.TAtyUserMapper" >
  <resultMap id="BaseResultMap" type="com.jk.provide.bean.TAtyUser" >
    <id column="C_ID" property="cId" jdbcType="VARCHAR" />
    <result column="C_LoginID" property="cLoginid" jdbcType="VARCHAR" />
    <result column="C_Name" property="cName" jdbcType="VARCHAR" />
    <result column="C_Password" property="cPassword" jdbcType="CHAR" />
    <result column="C_Mail" property="cMail" jdbcType="VARCHAR" />
    <result column="C_IP" property="cIp" jdbcType="VARCHAR" />
    <result column="C_XMJP" property="cXmjp" jdbcType="VARCHAR" />
    <result column="C_CORP" property="cCorp" jdbcType="VARCHAR" />
    <result column="C_DEPT" property="cDept" jdbcType="VARCHAR" />
    <result column="N_Valid" property="nValid" jdbcType="TINYINT" />
    <result column="N_Order" property="nOrder" jdbcType="SMALLINT" />
    <result column="userCode" property="usercode" jdbcType="VARCHAR" />
    <result column="userPost" property="userpost" jdbcType="VARCHAR" />
    <result column="C_ZW" property="cZw" jdbcType="VARCHAR" />
    <result column="C_LINKUSER" property="cLinkuser" jdbcType="VARCHAR" />
    <result column="N_RYLX" property="nRylx" jdbcType="INTEGER" />
    <result column="N_SHOW_USER" property="nShowUser" jdbcType="TINYINT" />
    <result column="N_TXL" property="nTxl" jdbcType="INTEGER" />
    <result column="N_SFKQ" property="nSfkq" jdbcType="TINYINT" />
  </resultMap>
  <sql id="Base_Column_List" >
    C_ID, C_LoginID, C_Name, C_Password, C_Mail, C_IP, C_XMJP, C_CORP, C_DEPT, N_Valid, 
    N_Order, userCode, userPost, C_ZW, C_LINKUSER, N_RYLX, N_SHOW_USER, N_TXL, N_SFKQ
  </sql>
    <select id="getAllUserList" resultMap="BaseResultMap" >
    select 
    <include refid="Base_Column_List" />
    from t_aty_user
  </select>
</mapper>

生产端:ServiceImpl

package com.jk.provide.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jk.provide.bean.TAtyUser;
import com.jk.provide.mapper.dao.TAtyUserMapper;
import com.jk.provide.service.IUserInfoService;

/** 
* @author 作者 尚峰: 
* @version 创建时间:2017年11月15日 上午10:14:20 
* 类说明 
*/
@Service("userservice")
public class UserInfoServiceImpl implements IUserInfoService {
	@Autowired
	private TAtyUserMapper tAtyUserMapper;

	@Override
	public List<TAtyUser> getAllUserList() {
		return tAtyUserMapper.getAllUserList();
	}

	@Override
	public String testRequest(TAtyUser user) {
		System.out.println(user.getcName());
		System.out.println(user.getcPassword());
		return "success";
	}
}

生产端:Service

package com.jk.provide.service;

import java.util.List;

import com.jk.provide.bean.TAtyUser;


/** 
* @author 作者 尚峰: 
* @version 创建时间:2017年11月15日 上午10:13:41 
* 类说明 
*/
public interface IUserInfoService {
	List<TAtyUser> getAllUserList();
	String  testRequest(TAtyUser user);
}


生产端:jdbc

#db driver
jdbc.driver=com.mysql.jdbc.Driver
#db url
jdbc.url=jdbc:mysql://localhost:3306/test2?useUnicode=true&characterEncoding=utf-8
#db username
jdbc.username=root
#db password
jdbc.password=root
#db maxActive
jdbc.maxActive=2
#db minIdle
jdbc.minIdle=5
#db maxIdle
jdbc.maxIdle=5

#\u6700\u592
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值