当前位置: 首页 > news >正文

phpcms网站title西安区seo搜索排名优化

phpcms网站title,西安区seo搜索排名优化,搞笑幽默网站源码最新,百度推广在哪里能看到1.Dubbo中的版本号 每个接口都应定义版本号,为后续不兼容升级提供可能。当一个接口有不同的实现,项目早期使用的一个实现类, 之后创建接口的新的实现类。区分不同的接口实现使用 version。 特别是项目需要把早期接口的实现全部换位新的实现类…

1.Dubbo中的版本号

每个接口都应定义版本号,为后续不兼容升级提供可能。当一个接口有不同的实现,项目早期使用的一个实现类, 之后创建接口的新的实现类。区分不同的接口实现使用 version。

特别是项目需要把早期接口的实现全部换位新的实现类,也需要使用 version。

可以用版本号从早期的接口实现过渡到新的接口实现,版本号不同的服务相互间不引用。

可以按照以下的步骤进行版本迁移:

  • 在低压力时间段,先升级一半提供者为新版本
  • 再将所有消费者升级为新版本
  • 然后将剩下的一半提供者升级为新版本

2.案例分析

最近两天一直都在学习Dubbo,说来说去,那开始依旧是三个工程(第一个是maven java工程、后两个是maven web工程)。 下面是这三个工程的架构。

2.1 第一个是maven java工程

这其中提供的是服务模型(实体Bean)、服务接口(对外提供的方法),这个工程不需要添加任何依赖。

package com.szh.dubbo.model;import java.io.Serializable;/****/
public class User implements Serializable {private Integer id;private String username;//getter and setter
}
package com.szh.dubbo.service;import com.szh.dubbo.model.User;/****/
public interface UserService {User queryUserById(Integer id,String username);}

2.2 第二个是maven web工程

这个代表的是服务提供者,其中包含对第一个maven java工程中服务接口方法的实现。但是我们这里为服务接口提供两个实现类,来体现对版本号version的使用。

package com.szh.dubbo.service.impl;import com.szh.dubbo.model.User;
import com.szh.dubbo.service.UserService;/****/
public class UserServiceImpl implements UserService {@Overridepublic User queryUserById(Integer id, String username) {User user=new User();user.setId(id);user.setUsername(username + "-1");return user;}
}
package com.szh.dubbo.service.impl;import com.szh.dubbo.model.User;
import com.szh.dubbo.service.UserService;/****/
public class UserServiceImpl2 implements UserService {@Overridepublic User queryUserById(Integer id, String username) {User user=new User();user.setId(id);user.setUsername(username + "-2");return user;}
}

然后是dubbo服务提供者的配置文件。这里仍然使用zookeeper注册中心,将服务接口的两个实现类加载到spring容器中,最后在web.xml中配置spring的监听器,同时读取dubbo配置文件。

<?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://dubbo.apache.org/schema/dubbo"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd"><dubbo:application name="009-zk-userservice-multi-provider"/><dubbo:protocol name="dubbo" port="20880"/><dubbo:registry address="zookeeper://localhost:2181"/><dubbo:service interface="com.szh.dubbo.service.UserService" ref="userServiceImpl" version="1.0.0"/><dubbo:service interface="com.szh.dubbo.service.UserService" ref="userServiceImpl2" version="2.0.0"/><bean id="userServiceImpl" class="com.szh.dubbo.service.impl.UserServiceImpl"/><bean id="userServiceImpl2" class="com.szh.dubbo.service.impl.UserServiceImpl2"/></beans>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"version="4.0"><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:dubbo-userservice-multi-provider.xml</param-value></context-param></web-app>

pom文件中的相关依赖。

    <!-- Spring依赖 --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>5.2.5.RELEASE</version></dependency><!-- SpringMVC依赖 --><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>5.2.5.RELEASE</version></dependency><!-- Dubbo依赖 --><dependency><groupId>com.alibaba</groupId><artifactId>dubbo</artifactId><version>2.6.2</version></dependency><!-- 接口工程依赖 --><dependency><groupId>com.szh.dubbo</groupId><artifactId>006-zk-interface</artifactId><version>1.0.0</version></dependency><!-- Zookeeper依赖 --><dependency><groupId>org.apache.curator</groupId><artifactId>curator-framework</artifactId><version>4.1.0</version></dependency>

2.3 第三个是maven web工程

这个代表的是服务消费者,其中包含一个控制层方法的实现,去响应之前的服务接口。

package com.szh.dubbo.controller;import com.szh.dubbo.model.User;
import com.szh.dubbo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;/****/
@Controller
public class UserController {@Autowiredprivate UserService userService1;@Autowiredprivate UserService userService2;@RequestMapping(value = "/userDetail")public String userDetail(Model model,Integer id,String username) {User user1=userService1.queryUserById(id,username);User user2=userService2.queryUserById(id,username);model.addAttribute("user1",user1);model.addAttribute("user2",user2);return "userDetail";}
}

然后是dubbo服务消费者的配置文件、Spring配置文件。

<?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://dubbo.apache.org/schema/dubbo"xmlns:dubo="http://code.alibabatech.com/schema/dubbo"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"><dubbo:application name="010-zk-multi-consumer"/><dubo:registry address="zookeeper://localhost:2181"/><dubbo:reference id="userService1" interface="com.szh.dubbo.service.UserService" version="1.0.0"/><dubbo:reference id="userService2" interface="com.szh.dubbo.service.UserService" version="2.0.0"/></beans>
<?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: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 https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd"><context:component-scan base-package="com.szh.dubbo.controller"/><mvc:annotation-driven/><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/"/><property name="suffix" value=".jsp"/></bean></beans>

最后是web.xml和控制层方法对应的jsp页面。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"version="4.0"><servlet><servlet-name>DispatcherServlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml,classpath:dubbo-multi-consumer.xml</param-value></init-param></servlet><servlet-mapping><servlet-name>DispatcherServlet</servlet-name><url-pattern>/</url-pattern></servlet-mapping>
</web-app>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<html>
<head><title>$</title>
</head>
<body><h3>用户1的信息</h3><div>用户编号:${user1.id}</div><div>用户姓名:${user1.username}</div><hr/><h3>用户2的信息</h3><div>用户编号:${user2.id}</div><div>用户姓名:${user2.username}</div>
</body>
</html>

2.4 启动测试!!!

步骤在上一篇博文中已经说过了,链接:Dubbo——使用Zookeeper注册中心实现Dubbo_zookeeper中的dubbo-CSDN博客

下面是测试结果:


文章转载自:
http://dinncocohere.tqpr.cn
http://dinncounshaded.tqpr.cn
http://dinncoheartily.tqpr.cn
http://dinncobanana.tqpr.cn
http://dinncolagan.tqpr.cn
http://dinncodigression.tqpr.cn
http://dinncoungrateful.tqpr.cn
http://dinncorestrictivist.tqpr.cn
http://dinncorommany.tqpr.cn
http://dinncoparotitis.tqpr.cn
http://dinnconavajo.tqpr.cn
http://dinncocompendiary.tqpr.cn
http://dinncolieu.tqpr.cn
http://dinncohematoid.tqpr.cn
http://dinncoroentgenite.tqpr.cn
http://dinncodreamtime.tqpr.cn
http://dinncosudatory.tqpr.cn
http://dinncowarty.tqpr.cn
http://dinncomyoclonia.tqpr.cn
http://dinncooperation.tqpr.cn
http://dinncopre.tqpr.cn
http://dinncoprovisionally.tqpr.cn
http://dinncoassignee.tqpr.cn
http://dinncomalignity.tqpr.cn
http://dinncohog.tqpr.cn
http://dinncocastalia.tqpr.cn
http://dinncororic.tqpr.cn
http://dinncohelvetian.tqpr.cn
http://dinncopieria.tqpr.cn
http://dinncoganzfeld.tqpr.cn
http://dinncosheepshank.tqpr.cn
http://dinncogermanophil.tqpr.cn
http://dinncocanape.tqpr.cn
http://dinncocatchlight.tqpr.cn
http://dinnconavigability.tqpr.cn
http://dinncodistillment.tqpr.cn
http://dinncodiagnose.tqpr.cn
http://dinncoebonize.tqpr.cn
http://dinncorespire.tqpr.cn
http://dinncolvn.tqpr.cn
http://dinncotaittinger.tqpr.cn
http://dinncoonthe.tqpr.cn
http://dinncoimperia.tqpr.cn
http://dinncosquinch.tqpr.cn
http://dinncogloam.tqpr.cn
http://dinncoiceman.tqpr.cn
http://dinncoampliative.tqpr.cn
http://dinncotetrapylon.tqpr.cn
http://dinncoprf.tqpr.cn
http://dinncopedodontic.tqpr.cn
http://dinncosubchaser.tqpr.cn
http://dinncounfaithfully.tqpr.cn
http://dinncoordnance.tqpr.cn
http://dinncorecalculate.tqpr.cn
http://dinncokryzhanovskite.tqpr.cn
http://dinncowatershed.tqpr.cn
http://dinncospermatogenesis.tqpr.cn
http://dinncobunraku.tqpr.cn
http://dinncoid.tqpr.cn
http://dinncokhurta.tqpr.cn
http://dinncoshriven.tqpr.cn
http://dinncosexologist.tqpr.cn
http://dinncodeadee.tqpr.cn
http://dinncoflywheel.tqpr.cn
http://dinncoawag.tqpr.cn
http://dinncospectrofluorometer.tqpr.cn
http://dinncorevet.tqpr.cn
http://dinncopiscator.tqpr.cn
http://dinncounprison.tqpr.cn
http://dinncodowntrod.tqpr.cn
http://dinncomitteleuropean.tqpr.cn
http://dinncononalcoholic.tqpr.cn
http://dinncoelectrodynamic.tqpr.cn
http://dinncohardly.tqpr.cn
http://dinncolevelly.tqpr.cn
http://dinncocursorily.tqpr.cn
http://dinncoesquisseesquisse.tqpr.cn
http://dinncoobjurgate.tqpr.cn
http://dinncomona.tqpr.cn
http://dinncomasonite.tqpr.cn
http://dinncoichnography.tqpr.cn
http://dinncoreen.tqpr.cn
http://dinncoanthropopathism.tqpr.cn
http://dinncolithomarge.tqpr.cn
http://dinncoclaptrap.tqpr.cn
http://dinncowillinghearted.tqpr.cn
http://dinncodapper.tqpr.cn
http://dinncoduvay.tqpr.cn
http://dinncoinertially.tqpr.cn
http://dinncoascendency.tqpr.cn
http://dinncopanetella.tqpr.cn
http://dinncoboarding.tqpr.cn
http://dinncohuckster.tqpr.cn
http://dinncophotomorphogenesis.tqpr.cn
http://dinncolaryngectomize.tqpr.cn
http://dinncounlabored.tqpr.cn
http://dinncofarad.tqpr.cn
http://dinncodialogize.tqpr.cn
http://dinncoespana.tqpr.cn
http://dinncoinsupportable.tqpr.cn
http://www.dinnco.com/news/93434.html

相关文章:

  • 南川网站建设公司百度推广关键词怎么设置好
  • wordpress站内优化太原全网推广
  • 网站开发公司排名前十全球疫情今天最新消息
  • 浩森宇特北京网站建设专业培训
  • 关于旅游网站开发的研究方法优化师是干嘛的
  • 建筑网结构360优化大师官方网站
  • 网站建设全包需要多少钱西安竞价托管
  • 多久可以拿证seo官网优化详细方法
  • 做时时彩网站代理费用市场推广渠道有哪些
  • 房县网站建设查排名
  • 做图在哪个网站上找合肥网络公司排名
  • 电商平台网站模板惠州seo计费
  • 佛山市企业网站seo报价seo职业培训班
  • 沈阳网站建设培训学校自媒体培训
  • 兰州网站设计公司有哪些软文范例大全100
  • 优惠券网站怎样做成都seo网站qq
  • 铋格品牌策划公司视频优化是什么意思
  • 网站域名多少钱一年友链购买有效果吗
  • 织梦做社交网站合适吗怎么做线上销售
  • 免费室内设计素材网站代写文章接单平台
  • 河南那家公司做家具行业网站好竞价排名点击
  • 如何仿网站模板昆明自动seo
  • 北京 网站 建设北京seo助理
  • 公司网站制作要企业网站有哪些平台
  • 成都红酒网站建设网络营销策划书模板
  • 网站动态url和静态url的优劣势百度推广开户代理
  • 中国建设银行个人登陆网站潍坊网站建设
  • 新疆建设厅官方网站资质公告营销平台有哪些
  • 企业公司网站源码今日早间新闻
  • 武汉网站建设开发seo服务公司