首页 > 免root版 > 免root框架和gg修改器_免root框架gg修改器下载
免root框架和gg修改器_免root框架gg修改器下载
  • 免root框架和gg修改器_免root框架gg修改器下载

  • 大小:11.84MB日期:2024-11-16 07:48:49
  • 语言:简体中文系统:Android
绿色无毒,安全可靠!部分设备误报拦截请通过!

应用详情

GG修改器破解版下载地址:https://ghb2023zs.bj.bcebos.com/d/z/p/d/dbzs.apk?GGXGQ

大家好,今天小编为大家分享关于免root框架和gg修改器_免root框架gg修改器下载的内容,赶快来一起来看看吧。

课程目标

1.走进电商

 3. 注册中心返回服务提供者地址列表给消费者,如果有变更,注册中心将基于长连接推

送变更数据给消费者。

 4. 服务消费者,从提供者地址列表中,基于软负载均衡算法,选一台提供者进行调用,

如果调用失败,再选另一台调用。

 5. 服务消费者和提供者,在内存中累计调用次数和调用时间,定时每分钟发送一次统计

数据到监控中心。

3.2注册中心Zookeeper

3.2.1 Zookeeper 介绍

官方推荐使用 zookeeper 注册中心。注册中心负责服务地址的注册与查找,相当于目录服务,服务提供者和消费者只在启动时与注册中心交互,注册中心不转发请求,压力较小。

Zookeeper 是 Apacahe Hadoop 的子项目,是一个树型的目录服务,支持变更推送,适合作为Dubbox 服务的注册中心,工业强度较高,可用于生产环境。

3.2.2 Zookeeper 在Linux系统的安装

安装步骤:

第一步:安装 jdk(此步省略,我给大家提供的镜像已经安装好JDK)

第二步:把 zookeeper 的压缩包(资源配套软件dubboxzookeeper-3.4.6.tar.gz)上传到 linux 系统。

Alt+P 进入SFTP ,输入put d:zookeeper-3.4.6.tar.gz 上传

第三步:解压缩压缩包

tar -zxvf zookeeper-3.4.6.tar.gz

第四步:进入 zookeeper-3.4.6 目录,创建 data 文件夹。

mkdir data

第五步:进入conf目录 ,把 zoo_sample.cfg 改名为 zoo.cfg

cd conf
mv zoo_sample.cfg zoo.cfg

第六步:打开zoo.cfg , 修改 data 属性:dataDir=/root/zookeeper-3.4.6/data

3.2.3 Zookeeper 服务启动

进入bin目录,启动服务输入命令

./zkServer.sh start

输出以下内容表示启动成功

关闭服务输入命令

./zkServer.sh stop

输出以下提示信息

查看状态:

./zkServer.sh status

如果启动状态,提示

如果未启动状态,提示:

3.3 Dubbox本地 JAR包部署与安装(了解)

Dubbox的jar包并没有部署到Maven的中央仓库中,大家在Maven的中央仓库中可以查找到Dubbo的最终版本是2.5.3 , 阿里巴巴解散了Dubbo团队后由当当网继续维护此项目,并改名为 Dubbox ,坐标不变,版本变更了,但是并没有提交到中央仓库。

我们现在需要手动将Dubbox的jar包安装到我的本地仓库中。

先将dubbo-2.8.4.jar包放到d:setup, 然后输入命令

mvn install:install-file -Dfile=d:setupdubbo-2.8.4.jar -.alibaba -DartifactId=dubbo -Dversion=2.8.4 -Dpackaging=jar

3.4配置离线约束

地址:

http://code./schema/dubbo/dubbo.xsd

3.5入门小Demo

3.5.1服务提供者开发

开发步骤:

(1)创建Maven工程(WAR)dubboxdemo-service ,在pom.xml中引入依赖

<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.0</modelVersion>
<groupId&.itcast.dubboxdemo</groupId>
<artifactId>dubboxdemo-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<spring.version>4.2.4.RELEASE</spring.version>
</properties>
<dependencies>
<!– Spring –>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<!– dubbo相关 –>
<dependency>
<groupId&.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.8.4</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId&.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.11.0.GA</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>piler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<!– 指定端口 –>
<port>8081</port>
<!– 请求路径 –>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</project>

(2)在工程的webapps下创建WEB-INF文件夹,创建web.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns=”http://java./xml/ns/javaee”
xsi:schemaLocation=”http://java./xml/ns/javaee http://java./xml/ns/javaee/web-app_2_5.xsd”
version=”2.5″>
<!– 加载spring容器 –>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext*.xml</param-value>
</context-param>
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>

(3)创建业务接口

创建包cn.itcast.dubbodemo.service,用于存放业务接口,创建接口

.itcast.dubbodemo.service;
/**
* 业务接口
* @author Administrator
*
*/
public interface UserService {
public String getName();
}

(4)创建业务实现类

创建包cn.itcast.dubbodemo.service.impl ,用于存放业务实现类。创建业务实现类:

.itcast.dubbodemo.service.impl;
.alibaba.dubbo.config.annotation.Service;
.itcast.dubbodemo.service.UserService;
@Service
public class UserServiceImpl implements UserService {
public String getName() {
return “itcast”;
}
}

注意:Service注解与原来不同,需要引入com.alibaba包下的

(5)编写配置文件

在src/main/resources下创建applicationContext-service.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:p=”http://www.springframework.org/schema/p”
xmlns:context=”http://www.springframework.org/schema/context”
xmlns:dubbo=”http://code./schema/dubbo” 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.xsd
http://code./schema/dubbo http://code./schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd”>

<dubbo:application name=”dubboxdemo-service”/>
<dubbo:registry address=”zookeeper://192.168.25.132:2181″/>
<dubbo:annotation package=”cn.itcast.dubboxdemo.service” />
</beans>

注意:dubbo:annotation用于扫描@Service注解。

(6)测试运行

tomcat7:run

3.5.2服务消费者开发

开发步骤:

(1)创建Maven工程(WAR)dubboxdemo-web ,在pom.xml引入依赖 ,同“dubboxdemo-service”工程。区别就是把tomcat插件的运行端口改为8082 。

(2)在webapps目录下创建WEB-INF 目录,并创建web.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns=”http://java./xml/ns/javaee”
xsi:schemaLocation=”http://java./xml/ns/javaee http://java./xml/ns/javaee/web-app_2_5.xsd”
version=”2.5″>
<!– 解决post乱码 –>
<filter>
<filter-name>CharacterEncodingFilter</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>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!– 指定加载的配置文件 ,通过参数contextConfigLocation加载–>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext-web.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>

(3)拷贝业务接口

将“dubboxdemo-service”工程的cn.itcast.dubboxdemo.service 包以及下面的接口拷贝至此工程。

(4)编写Controller

.itcast.dubboxdemo.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
.itcast.dubbodemo.service.UserService;
@Controller
@RequestMapping(“/user”)
public class UserController {
@Reference
private UserService userService;
@RequestMapping(“/showName”)
@ResponseBody
public String showName(){
return userService.getName();
}
}

(5)编写spring配置文件

在src/main/resources下创建applicationContext-web.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:p=”http://www.springframework.org/schema/p”
xmlns:context=”http://www.springframework.org/schema/context”
xmlns:dubbo=”http://code./schema/dubbo” 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.xsd
http://code./schema/dubbo http://code./schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd”>
<mvc:annotation-driven >
<mvc:message-converters register-defaults=”false”>
<bean class=”org.springframework.http.converter.StringHttpMessageConverter”>
<constructor-arg value=”UTF-8″ />
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!– 引用dubbo 服务 –>
<dubbo:application name=”dubboxdemo-web” />
<dubbo:registry address=”zookeeper://192.168.25.132:2181″/>
<dubbo:annotation package=”cn.itcast.dubboxdemo.controller” />
</beans>

(6)测试运行

tomcat7:run

在浏览器输入http://localhost:8082/user/showName.do,查看浏览器输出结果

3.6管理中心的部署

我们在开发时,需要知道注册中心都注册了哪些服务,以便我们开发和测试。我们可以通过部署一个管理中心来实现。其实管理中心就是一个web应用,部署到tomcat即可。

3.6.1管理端安装

(1)编译源码,得到war包

给大家下发的资源中有个dubbox-master.zip ,这个是dubbox的源码,我们可以使用maven命令编译源码得到“管理端”的war包

将此压缩包解压,在命令符下进入dubbo-admin目录 ,输入maven命令

mvn package -Dmaven.skip.test=true

如果你看到如下信息,就说明成功了

(2)进入target文件夹,你会看到一个dubbo-admin-2.8.4.war , 在linux服务器上安装tomcat, 将此war包上传到linux服务器的tomcat的webapps下。为了访问方便,你可以把版本号去掉。 启动tomcat后自动解压。

(3)如果你部署在zookeeper同一台主机并且端口是默认的2181,则无需修改任何配置。如果不是在一台主机上或端口被修改,需要修改WEB-INF下的dubbo.properties ,修改如下配置:

dubbo.registry.address=zookeeper://127.0.0.1:2181

修改后重新启动tomcat

3.6.2管理端使用

(1)打开浏览器,输入http://192.168.25.132:8080/dubbo-admin/ ,登录用户名和密码均为root 进入首页。 (192.168.25.132:)是我部署的linux主机地址。

(2)启动服务提供者工程,即可在服务治理-提供者查看到该服务。

点击其中一条数据后可以查看详情。

(3)启动服务消费者工程,运行页面,观察“消费者”列表

4.品优购-框架搭建

4.1工程结构分析与设计

最终完整的工程结构如下:

工程说明:

pinyougou-parent 聚合工程

pinyougou-pojo 通用实体类层

pinyougou-dao 通用数据访问层

pinyougou-xxxxx-interface 某服务层接口

pinyougou-xxxxx-service 某服务层实现

pinyougou-xxxxx-web 某web工程

4.2创建数据库表

执行资源文件夹中pinyougou-db.sql

4.3搭建框架

4.3.1父工程

创建Maven工程pinyougou-parent (POM) ,groupId 为com.pinyougou ,artifactId 为pinyougou-parent , 在pom.xml中添加锁定版本信息dependencyManagement与pluginManagement,详见“资源/配置文件/第一天搭建/父工程/pom.xml”。

以下模块均继承自此父工程

4.3.2通用实体类模块

创建通用实体类模块-pinyougou-pojo

4.3.3通用数据访问模块

创建通用数据访问模块pinyougou-dao .添加依赖Mybatis和pinyougou-pojo

<dependencies>
<!– Mybatis –>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>
<dependency>
<groupId&.github.miemiedev</groupId>
<artifactId>mybatis-paginator</artifactId>
</dependency>
<!– MySql –>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!– 连接池 –>
<dependency>
<groupId&.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<dependency>
<groupId&.pinyougou</groupId>
<artifactId>pinyougou-pojo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>

将“配置文件/第一天搭建/数据访问层工程”下的配置文件拷贝到pinyougou-dao工程

4.3.4通用工具类模块

创建通用工具类模块mon

4.3.5商家商品服务接口模块

创建maven(jar)模块pinyougou-sellergoods-interface , pom.xml添加依赖

<dependencies>
<dependency>
<groupId&.pinyougou</groupId>
<artifactId>pinyougou-pojo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>

4.3.6商家商品服务模块

创建maven(war)模块pinyougou-sellergoods-service ,pom.xml引入依赖

<dependencies>
<!– Spring –>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<!– dubbo相关 –>
<dependency>
<groupId&.alibaba</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId&.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId&.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId&mons-codec</groupId>
<artifactId&mons-codec</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId&.pinyougou</groupId>
<artifactId>mon</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId&.pinyougou</groupId>
<artifactId>pinyougou-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId&.pinyougou</groupId>
<artifactId>pinyougou-sellergoods-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<!– 配置Tomcat插件 –>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/</path>
<port>9001</port>
</configuration>
</plugin>
</plugins>
</build>
</project>

在webapps下创建WEB-INF/web.xml ,加载spring容器

<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns=”http://java./xml/ns/javaee”
xsi:schemaLocation=”http://java./xml/ns/javaee http://java./xml/ns/javaee/web-app_2_5.xsd”
version=”2.5″>
<!– 加载spring容器 –>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/applicationContext*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>

创建包com.pinyougou.sellergoods.service.impl

在src/main/resources下创建spring/applicationContext-service.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:p=”http://www.springframework.org/schema/p”
xmlns:context=”http://www.springframework.org/schema/context”
xmlns:dubbo=”http://code./schema/dubbo” 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.xsd
http://code./schema/dubbo http://code./schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd”>
<dubbo:protocol name=”dubbo” port=”20881″></dubbo:protocol>
<dubbo:application name=”pinyougou-sellergoods-service”/>
<dubbo:registry address=”zookeeper://192.168.25.129:2181″/>
<dubbo:annotation package=”com.pinyougou.sellergoods.service.impl” />
</beans>

4.3.7运营商管理后台

创建maven(war)模块pinyougou-manager-web , pom.xml引入依赖

<dependencies>
<!– Spring –>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<!– dubbo相关 –>
<dependency>
<groupId&.alibaba</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId&.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId&.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId&mons-codec</groupId>
<artifactId&mons-codec</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId&.pinyougou</groupId>
<artifactId>mon</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId&.pinyougou</groupId>
<artifactId>pinyougou-sellergoods-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<!– 配置Tomcat插件 –>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/</path>
<port>9101</port>
</configuration>
</plugin>
</plugins>
</build>

在webapps下创建WEB-INF/web.xml ,加载spring容器

<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns=”http://java./xml/ns/javaee”
xsi:schemaLocation=”http://java./xml/ns/javaee http://java./xml/ns/javaee/web-app_2_5.xsd”
version=”2.5″>
<!– 解决post乱码 –>
<filter>
<filter-name>CharacterEncodingFilter</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>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!– 指定加载的配置文件 ,通过参数contextConfigLocation加载–>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/springmvc.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>

创建包com.pinyougou.manager.controller

在src/main/resources下创建spring/springmvc.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:p=”http://www.springframework.org/schema/p”
xmlns:context=”http://www.springframework.org/schema/context”
xmlns:dubbo=”http://code./schema/dubbo” 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.xsd
http://code./schema/dubbo http://code./schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd”>
<mvc:annotation-driven>
<mvc:message-converters register-defaults=”true”>
<bean class=”com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter”>
<property name=”supportedMediaTypes” value=”application/json”/>
<property name=”features”>
<array>
<value>WriteMapNullValue</value>
<value>WriteDateUseDateFormat</value>
</array>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!– 引用dubbo 服务 –>
<dubbo:application name=”pinyougou-manager-web” />
<dubbo:registry address=”zookeeper://192.168.25.132:2181″/>
<dubbo:annotation package=”com.pinyougou.manager.controller” />
</beans>

4.3.8商家管理后台

构建web模块pinyougou-shop-web 与运营商管理后台的构建方式类似。区别:

(1)定义tomcat的启动端口为9102

(2)springmvc.xml

<!– 引用dubbo 服务 –>
<dubbo:application name=”pinyougou-shop-web” />
<dubbo:registry address=”zookeeper://192.168.25.132:2181″/>
<dubbo:annotation package=”com.pinyougou.shop.controller” />

4.4实体类与数据访问层模块

4.4.1 生成代码

利用反向工程generatorSqlmapCustom实现实体类与数据访问层代码的自动生成

4.4.2 拷贝代码

将com.pinyougou.pojo包拷贝到pojo工程

将com.pinyougou.mapper包和resouce下的com.pinyougou.mapper文件夹拷贝到dao工程

4.4.3 修改实体类代码

修改每个实体类,让其实现Serializable接口

5.品牌列表-后端代码

5.1需求分析

完成品牌管理的后端代码,在浏览器可查询品牌的数据(json格式)

5.2数据库表

tb_brand 品牌表

字段类型长度含义IdBigint主键NameVarchar255品牌名称First_charVarchar1品牌首字母

5.3后端代码

5.3.1 服务层接口

在pinyougou-sellergoods-interface 工程创建BrandService接口

.pinyougou.sellergoods.service;
import java.util.List;
.pinyougou.pojo.TbBrand;
/**
* 品牌服务层接口
* @author Administrator
*
*/
public interface BrandService {
/**
* 返回全部列表
* @return
*/
public List<TbBrand> findAll();
}

5.3.2 服务实现类

在pinyougou-sellergoods-service 工程创建BrandServiceImpl类

.pinyougou.sellergoods.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
.alibaba.dubbo.config.annotation.Service;
.pinyougou.mapper.TbBrandMapper;
.pinyougou.pojo.TbBrand;
.pinyougou.sellergoods.service.BrandService;
@Service
public class BrandServiceImpl implements BrandService {
@Autowired
private TbBrandMapper brandMapper;
@Override
public List<TbBrand> findAll() {
return brandMapper.selectByExample(null);
}
}

5.3.3 控制层代码

在pinyougou-manager-web工程创建com.pinyougou.manager.controller包,包下创建BrandController类

.pinyougou.manager.controller;
import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
.alibaba.dubbo.config.annotation.Reference;
.pinyougou.pojo.TbBrand;
.pinyougou.sellergoods.service.BrandService;
/**
* 品牌controller
* @author Administrator
*/
@RestController
@RequestMapping(“/brand”)
public class BrandController {
@Reference
private BrandService brandService;
/**
* 返回全部列表
* @return
*/
@RequestMapping(“/findAll”)
public List<TbBrand> findAll(){
return brandService.findAll();
}
}

5.4测试

启动pinyougou-sellergoods-service

启动pinyougou-manager-web

地址栏输入http://localhost:9101/brand/findAll.do

可以看到浏览器输出了json数据。

附录:常见错误

1.在注册中心找不到对应的服务

java.lang.IllegalStateException: Failed to check the status of the .pinyougou.sellergoods.service.BrandService. No provider available for the .pinyougou.sellergoods.service.BrandService from the url zookeeper://192.168.25.129:.alibaba.dubbo.registry.RegistryService?application=pinyougou-manager-web&dubbo=2.8.4&.pinyougou.sellergoods.service.BrandService&methods=update,get,delete,selectOptionList,add,getListByPage&pid=3980&revision=0.0.1-SNAPSHOT&side=consumer&timestamp=1501146823396 to the consumer 172.16.17.14 use dubbo version 2.8.4

这种错误是服务层代码没有成功注册到注册中心导致,请检查一下你的服务层代码是否添加了@service注解,并且该注解的包一定是com.alibaba.dubbo.config.annotation包,不是org.springframework.stereotype.Service,这个地方极容易出错。另外还有一个原因就是你的服务层工程由于某些原因没有正常启动,也无法注册到注册中心里。

2.无法连接到注册中心

org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 5000 org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:876) org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98) org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:92) org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:80)
com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkclientZookeeperClient.<init>(ZkclientZookeeperClient.java:26)

请检查IP与端口是否填写正确,检查注册中心是否正常启动

以上就是关于免root框架和gg修改器_免root框架gg修改器下载的全部内容,感谢大家的浏览观看,如果你喜欢本站的文章可以CTRL+D收藏哦。

相关文章

热门下载

大家还在搜