1 distribué
1.1 Qu'est-ce qui est distribué
1.2 La différence entre distribution et grappes
Il s'avère qu'il n'y a qu'un seul chef dans le petit restaurant, qui coupe les légumes, lave les légumes, prépare les ingrédients et les fait tous les sauter. Plus tard, il y avait plus de clients et un chef dans la cuisine était trop occupé, alors il a embauché un autre chef. Les deux chefs pourraient cuisiner les mêmes plats. La relation entre ces deux chefs était un cluster. Afin de laisser le chef se concentrer sur la cuisson et faire de son mieux, il a engagé un plat d'accompagnement pour être responsable de la coupe des légumes, de la préparation de la vaisselle et de la préparation des ingrédients. La relation entre le chef et le plat d'accompagnement est distribuée, et un plat d'accompagnement est trop occupé, il a donc embauché un plat d'accompagnement, et la relation entre le plat d'accompagnement est un cluster.
2. Construisez un projet distribué
Outils de préparation: Eclipse, VMWarm équipé du système CentOS7, Zookeeper .... La chose la plus importante est une machine âgée de trois ans.
1 Créez d'abord un projet maven de la classe parent, et la méthode d'emballage est POM.
Créez un projet Maven de classe parent dans Eclipse, et la méthode d'emballage est POM. Pourquoi créer un projet Maven de classe parent? Parce que vous souhaitez utiliser ce projet Maven pour gérer diverses versions de package JAR, si la sous-classe souhaite directement le package JAR et la classe parent, vous pouvez le faire. xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance" xsi: schemalation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <ModelVersion> 4.0.0 </ Modelversion> <ProupId> com.itqf </proncId> <ArtifActid> Sing-parente </ artifactid> <version> 0.0.1-snapshot </De version> <packaging> Pom </ Package> packages de pot -> <propriétés> <junit.version> 4.12 </ junit.version> <printemps.version> 4.2.4.release </spring.version> <mybatis.version> 3.2.8 </mybatis.version> <mybatis.spring.version> 1.2.2 < /mybatis.spring.version><mybatis.paginator.version>1.2.15</mybatis.paginator.Version><Mysql.version>5.1.32</mysql.version> RSION> <Jackson.Version> 2.4.2 </jackson.version> <druid.version> 1.0.9 </druid.version> <httpclient.version> 4.3.5 </httpclient.version> <jstl.version> 1.2 </ jstl .Version> <servlet-api.version> 2.5 </servlet-api.version> <jsp-api.version> 2.0 </jsp-api.version> <joda-time.version> 2.5 </joda-time.version> <commons-Lang3.ve RSION> 3.3.2 </commons-Lang3.Version> <commons-io.version> 1.3.2 </commons-io.version> <commons-net.version> 3.3 </commons net.version> <pagehelper.version> 3.4. 2-fix </pagehelper.version> <jsqlparser.version> 0.9.1 </jsqlparser.version> <commons-fileupload.version> 1.3.1 </commons-fileupload.version> <Jedis.version> 2.7 .2 </Jedis.version> <solrj.version> 4.10.3 </solrj.version> <bbo.version> 2.5.3 </dubbo.version> <Zookeeper.Version> 3.4.7 </zookeeper.version> <zkclient.versio n> 0.1 </zkclient.version> <activemq.version> 5.11.2 </activemq.version> <freemarker.version> 2.3.23 </fremarker.version> <Quartz.version> 2.2.2 </quartz.version> </properties> <! - Gérer les packages JAR utilisés dans tous les projets, sans dépendances réelles -> <dedentencymanagement> <Dependces> <! - Time Operation Component -> <Dependency> <ProupId> joda-time </rom grouped>
2 Créez un projet d'agrégation Maven.
2.1 Créez un projet d'agrégation Maven et héritez du projet parent.
Ingénierie d'agrégation: la couche de contrôleur, la couche de vue, etc. Dans le projet, peut être formée indépendamment dans un projet et enfin intégré dans un projet lorsqu'il est enfin exécuté.
pom.xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance" xsi: schemalation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <ModelVersion> 4.0.0 </ Modelversion> <parent> <proupId> com.itqf </ groupeid> <Artifactid> Sing-Parent </ artifactid> <version> 0.0.1-snapshot </Dero version> </parent> <ArtefactId> Sing-Manager </ ArtifactId> <Sease> 0.0.1-Snapshot </DERNIFRATION> <Packaging> Pom </packaging> <Dendencys> <Dendency> <ProupId> com.itqf </proncId> <Artefactid> Sing-Common </ Artifactid> <frisert> 0.0.1-Snapshot </Dersion> </Dependance> <Duild> <Glugins> <Glugin> <ProupId> org.apache.tomcat.maven </prôdId> <ArtifActid> Tomcat7-Maven-Plugin </ ArtifactId> <FIFIGIGURATION> <port> 8083 </port> <path> / </ path> </finiguration> </ plugin> </gluns> </nubuild> </ Modules> <Dodules> Sing-Manager-Pojo </ Module> <Dodule> Sing-Manager-Interface </Dodule> <Dodule> Sing-Manager-Service </odule> <Dodule> Sing-Manager-Mapper </dudule> </odulales> </rands>
2.2 Créez un module Maven dans le projet d'agrégation et nommez-le Sping-Manager-Pojo (couche de classe d'entité).
Pojo est un format JAR normal et n'a pas besoin de s'appuyer sur le projet parent.
pom.xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance" xsi: schemalation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <ModelVersion> 4.0.0 </ ModelVersion> <parent> <ProupId> com.itqf </proncId> <Ertifactid> Sing-Manager </ artifactid> <version> 0.0.1-Snapshot </Derson> </parent> <ArtefactId> Sing-Manager-Pojo </letefactId> </randing>
2.3 Créez un module Maven dans le projet d'agrégation et nommez le Spring-Manager-Mapper (couche DAO). Comptez sur Pojo dans le fichier pom.xml. Étant donné que la méthode de la couche de mappeur renvoie un objet de classe d'entité, Pojo doit être utilisé.
Packages JAR de dépendance d'importation.
xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance" xsi: schemalation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <ModelVersion> 4.0.0 </ ModelVersion> <parent> <ProupId> com.itqf </proncId> <Ertifactid> Sing-Manager </ artifactid> <version> 0.0.1-Snapshot </Derson> </parent> <ArtefactId> Sing-Manager-Mapper </letefactId> <! - Dependency Pojo -> <Detendances> <Dependency> <GroupId> com.itqf </proncId> <ArtifActid> Sing-Manager-Pojo </Retifactid> <Dersion> 0.0.1-Snapshot </Sease> </Dendency> <! - MYBATIS -> <dependency> <groupId> org.mybatis </prôdId> <Ertifactid> Mybatis </ artifactid> <in version> $ {Mybatis.version} </DERNIFRIENT> </DENDENCENCE> <Dependance> < GroupID> org.mybatis </prômId> <Artifactid> Mybatis-Spring </ ArfactId> <Dersion> $ {mybatis.spring.version} </ version> </dependency> <dependency> <Gro upId> com.github.miemediev </prouprid> <letifactive> mybatis-paginator </refactive> <version> $ {mybatis.paginator.version} </ version> </Dedency> <de Pendency> <proupId> com.github.pagehelper </prôdId> <ArtifactId> PageHelper </Retifactid> <Dersion> $ {Pagehelper.Version} </ Version> </Dependency> <! - MySQL -> <dependency> <GroupId> MySQL </rompuprid> <ArtifACTID> MySQL-Connector-Java </ ArtifactId> <Dersion> $ {MySQL.Version} </ Version> </Dependance> <! - Connexion Pool -> <dependency> <proupId> com.alibaba </prôdId> <ArtifactId> Druid </etefactive> <DERSE> $ {druid.version} </-version> </dependency> </pedidensence> </randing> 2.4 Créez une interface Spring-Manager (Interface) dans le projet d'agrégation et placez toutes les interfaces de service dans un projet indépendant. Si la valeur de retour de la méthode dans l'interface est une classe d'entité, POJO est requis. Par conséquent, cela dépend de Pojo xml dans POM.
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance" xsi: schemalation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <ModelVersion> 4.0.0 </ ModelVersion> <parent> <ProupId> com.itqf </proncId> <Ertifactid> Sing-Manager </ artifactid> <version> 0.0.1-Snapshot </Derson> </parent> <ArtefactId> Sing-Manager-Interface </ ArtifactId> <Dependance> <Dependency> <proupId> com.itqf </prouprid> <ArtifActid> Sing-Manager-Pojo </ Artifactid> <DersonD> 0.0.1-Snapshot </DERNIERDS>
2.5 Créer un service Spring-Manager (classe d'implémentation d'interface) dans le projet d'agrégation. La méthode d'emballage est la guerre
Étant donné que la couche de contrôleur est séparée de la couche de service, lors de l'exécution et du démarrage, le contrôleur et le service doivent être publiés séparément à l'aide de TomCat, et tous les fichiers de configuration requis dans le projet d'agrégation sont placés dans le service, afin que tous les fichiers de configuration soient chargés et intégrés au démarrage de Tomcat.
Fichier de configuration
SqlMapConfig.xml
<? xml version = "1.0" encoding = "utf-8"?> <! doctype ConfigurationPublic "- // mybatis.org//dtd config 3.0 // en" "http://mybatis.org/dtd/mybatis-3config.dtd"> <configuration> </mybatis>
db.properties
db.driver = com.mysql.jdbc.driverdb.url = jdbc: mysql: // localhost: 3306 / taOtao? Caractarencoding = utf-8db.userName = rootdb.password = root
applicationContext-tx.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/s Chema / Context "XMLNS: MVC =" http://www.springframework.org/schema/mvc "xmlns: tx =" http: //www.springfrfrfr Amework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:dubbo="http://c ode.alibabatech.com/schema/dubbo"xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.xsdd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsdd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd "> <bean id =" txmanager "> <propriété name =" dataSource "ref =" dataSource "> </ Property> id = "conseilsId" transaction-manager = "txManager"> <tx: attributs> <tx: méthode name = "add *" propagation = "requise" /> <tx: méthode name = "Save *" propagation = "requis" /> <tx: méthode name = "insert *" propagation = "requis" /> <tx: méthode name = "INSERT *" Pro propagation = " name = "update *" propagation = "requis" /> <tx: méthode name = "del *" propagation = "requise" /> <tx: méthode name = "find *" propagation = "supports" readly = "true" /> <tx: méthode name = "get *" propagation = "supports" lecture = "true" /> </ tx: attributes> <aop: Advisor conseils-ref = "CONSEILID" POINTCUT = "EXECUTION (* com.itqf.service .. *. * (..))" /> </ aop: config> </bans>
applicationContext-dao.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/contex amework.org/schema/mvc"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.xsdd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd "> <context: propriété-placeholder location =" classpath: ressource / *. Properties "/> <bean id =" dataSource "> <propriété name =" driverclassname "value =" $ {db.driver} "> </ property nom =" $ {db.driver} "> Value = "$ {db.url}"> </ propriété> <propriété name = "username" value = "$ {db.username}"> </ propriété> <propriété name = "passway" value = "$ {db.password}"> </ propriété> <propriété name = "maxactive" value = "10"> </ propriété> <propriété name = "MinIdle" Value = "5"> </ Property> </ Property <anan> <propriété name = "dataSource" ref = "dataSource"> </ propriété> <propriété name = "configLocation" value = "classpath: mybatis / sqlmapconfig.xml"> </ propriété> </ank 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/contex amework.org/schema/mvc"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.xsdd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd "> <context: composant-scan basage =" com.itqf.service "> </ context: composant-scan> </ beans>
pom.xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance" xsi: schemalation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <Modelversion> 4.0.0 </ Modelversion> <parent> <ProupId> com.qianfeng </proupId> <Ertifactid> Sing-Manager </ Artifactid> <version> 0.0.1-SNAPSHOT </ version> </parent> <ArtefactId> Sing-Manager-Service </ ArfactId> <Packaging> War </ Packaging> <Dependances> <Dependency> <ProupId> com.qianfeng </proupId> <Artifactid> Sing-Manager-Interface </Retifactid> <DersonD> 0.0.1-Snapshot </Derowet> </Dedency> <Dedency> <ArtefactId> Sing-Manager-Mapper </Retifactid> <Dersion> 0.0.1-Snapshot </DERNIERSE> </DENDENCENCE> <! - Spring -> <dependency> <proupId> org.springframework </rompuprid> <letifactive> printemps-context </ artifactid> <version> $ {printemps.springframework </proupId> <pedidency> <proupId> org.springframework </proupId> <Artifactid> Spring Beans </Artifactid> <Dudition> {Sp> {spor Ring.Version} </ Version> </ Dependency> <Dedency> <ProupId> org.SpringFramework </promIdD> <ArtifActid> printemps-webmvc </ artifactid> <fri version> $ {printemps.sversion} </-version> </peedency> <peediCT> <proupId> org.SpringFramework </prouvend> <ArtifActid> Spring-Org.SpringFramework </prouvend> <ArtifActid> Spring-Org.SpringFramework </prouvenD> JDBC </ ArfactId> <Dersion> $ {Spring.Version} </ Version> </ Dependency> <Dependance> <GroupId> Org.SpringFramework </rom grouped> <ArtifActid> Spring-Aspects </ Artifactid> <Dersond> $ {Spring.Version} </Severse> </Dedency> <pedency> <groupen RK </rompuprid> <Artifactid> printemps-jms </ artifactive> <in version> $ {printemps.version} </ version> </dependency> <dependency> <proupId> org.springframework </proupId> <Artefactive> Spring-Context-Support </ Artifactid> <version> $ {Spring.Version} </ version>Structure d'ingénierie finale
3 Utilisez Dubbo pour publier le service
Pensez d'abord?
Les sites Web des centres commerciaux comme Taobao et JD peuvent non seulement se connecter du côté PC, mais aussi du côté du téléphone mobile. Comment est-il implémenté? Écrire deux contrôleurs? Ce n'est certainement pas. Qui n'aura rien à faire quand vous n'avez rien à faire? Ensuite, cela nécessite l'utilisation de SOA (architecture orientée services). Lorsque nous écrivons un projet à l'aide de distribution, il y aura de nombreux systèmes pour s'appeler. Si vous faites des allers-retours, la structure du code sera très déroutante. Ici, nous utilisons Dubbo pour parvenir à résoudre le problème de trop de services de publication et à ne pas être clair à ce sujet.
Qu'est-ce que SOA
SOA est une méthode de conception qui comprend plusieurs services, et les services fourniront éventuellement une série de fonctions grâce à la coopération. Un service existe généralement sous une forme indépendante dans un processus de système d'exploitation. Les services communiquent via le réseau, plutôt que par des appels en cours.
Par exemple, vous avez maintenant de nombreux services: services d'information (fournissant des communiqués de presse, visualisation, modification, suppression), services de commande (ajout de commande, modification de la commande, visualisation des commandes, suppression des commandes, etc.) Services financiers (revenus, dépenses, statistiques, etc.) Services des employés (nouveaux statistiques).
dubo
Qu'est-ce que Dubbo (un outil de gestion pour la planification des ressources et le centre de gouvernance)
Avec le développement d'Internet, l'ampleur des applications de site Web a été continuellement élargie et les architectures d'applications verticales conventionnelles ne peuvent plus y faire face. Les architectures de service distribuées et les architectures informatiques mobiles sont impératives. Un système de gouvernance est urgent pour assurer l'évolution ordonnée de l'architecture.
Architecture d'application unique
Architecture d'application verticale
Architecture de service distribuée
Architecture compromis de flux
Construction de l'environnement de Dubbo:
DESCRIPTION DES RODES DE NODE:
Description de la relation d'appel:
Ici, nous arrivons principalement au Registry Center (Registry), et nous utilisons Zookeeper pour agir comme centre de registre.
Déployez le registre dans l'environnement Linux, Zookeeper
La première étape est bien sûr d'allumer la machine virtuelle, donc je le ferai dans CentOS7.
Obtenez un package compressé Zookeeper en ligne, le mien est Zookeeper-3.4.6.tar.gz
Collez dans le répertoire / opt et décompressez. (L'environnement JDK est requis. S'il n'y a pas d'environnement JDK, installez d'abord un JDK)
Entrez le répertoire ZooKeeper-3.4.6 et créez un dossier appelé données.
Renommer zoo_sample.cfg dans le répertoire ./conf à zoo.cfg modifie l'attribut de données dans zoo.cfg: datadir = / opt / zookeeper-3.4.6 / data
Étape 7:
Notez qu'après le démarrage du zookeeper, vous devez éteindre le pare-feu !!! C'est ça.
Ajoutez un fichier de configuration au service ApplicationContext-Service.xml pour publier le service
<!-- Use dubbo to publish the service --> <!-- Indicate the project where the service is located --> <dubbo:application name="sing-manager"/> <!-- Indicate the registry address is the IP address in Linux plus the port number, and the default port number of zookeeper is 2181 --> <dubbo:registry protocol="zookeeper" address="10.0.117.198:2181" > </ Dubbo: Registry> <! - Exposez le service à un certain numéro de port de port, sélectionnez un port qui n'est pas occupé -> <dubbo: protocole name = "Dubbo" port = "20888"> </ dubbo: protocole> <! - Exposez le service à un certain numéro de port de port de port, sélectionnez un port qui n'est pas occupant -> <dubbo: protocol nom = "Dubbo" Port = "20888"> </ Dubbo: ProtoCol> <! - Ref est le nom de l'objet de service créé par le conteneur de printemps -> <dubbo: service interface = "com.itqf.service.itemService" ref = "itemServiceIMPl" timeout = "6000000"> </ dubbo: service>
Importer des packages dans le service POM.xml
<! - Dubbo-lié -> <dependency> <proupId> com.alibaba </prouvenid> <ArtefactId> Dubbo </letefactive> <! - Exclure les dépendances -> <exclusions> <exclusion> <proupId> org.springframework </rom grouped> <Artifactid> printemps </ artifactid> </clusion> <cordsion> <proupId> org.jboss.netty </prouvenid> <artifactid> netty </tatifactid> </clusion> </clusion > / dépendance> <dependency> <proupId> org.apache.zookeeper </rom groupeid> <letifactive> zookeeper </ artifactive> </dependency> <dependency> <proupId> com.github.sgroschupf </prouvendid> <artifactid> zkclient </Rifactid> </sendency>
4 Créez un contrôleur Spring-Manager, qui est au même niveau que le projet agrégé. Les dépendances d'importation.
Le Consoler doit utiliser Dubbo pour accéder au service publié par la couche de service. Pour utiliser le serveur Tomcat pour la publication, bien sûr, SpringMVC est également nécessaire.
xml
<Dependances> <! - Comptez simplement sur l'interface de service -> <dependency> <proupId> com.qianfeng </proupId> <ArtefactId> Sing-Manager-Interface </ ArfactId> <Dersion> 0.0.1-Snapshot </DERNIFRICATION> -> <dependency> <proupId> org.springframework </rompuprid> <letifactive> printemps-context </ artifactid> <version> $ {printemps.springframework </proupId> <pedidency> <proupId> org.springframework </proupId> <Artifactid> Spring Beans </Artifactid> <Dudition> {Sp> {spor Ring.Version} </ Version> </ Dependency> <Dedency> <ProupId> org.SpringFramework </promIdD> <ArtifActid> printemps-webmvc </ artifactid> <fri version> $ {printemps.sversion} </-version> </peedency> <peediCT> <proupId> org.SpringFramework </prouvend> <ArtifActid> Spring-Org.SpringFramework </prouvend> <ArtifActid> Spring-Org.SpringFramework </prouvenD> JDBC </ ArfactId> <Dersion> $ {Spring.Version} </ Version> </ Dependency> <Dependance> <GroupId> Org.SpringFramework </rom grouped> <ArtifActid> Spring-Aspects </ Artifactid> <Dersond> $ {Spring.Version} </Severse> </Dedency> <pedency> <groupen RK </rompuprid> <Artifactid> printemps-jms </ artifactive> <version> $ {printemps.version} </ version> </ Dependency> <Dedency> <ProupId> org.springFramework </proupId> <ArtefactId> Spring-Context-Support </ptericence> <version> $ {Spring.Version} </ version> </ Depenvence> Lié à JSP -> <dependency> <groupId> jstl </prôdId> <ErtifactId> JSTL </ artifactId> </Dependency> <Dedency> <ProupId> javax.servlet </proupId> <ArtifActid> servlet-api </ a rtifactid> <ccope> fourni </ccope> </ dépendance> <dependency> <proupId> javax.servlet </rom groupeid> <lefactive> jsp-api </ artifactid> <ccope> fourni </ccope> </dependency> <! - lié à Dubbo -> <dependency> <proupId> com.alibaba </rompuprid> <artifactId> Dubbo </retifactid> <! - Exclure les dépendances -> <exclusions> <exclusion> <proupId> org.springframework </rom grouped> <Artifactid> printemps </ artifactid> </clusion> <cordsion> <proupId> org.jboss.netty </prouvenid> <artifactid> netty </tatifactid> </clusion> </clusion > / dépendance> <dependency> <proupId> org.apache.zookeeper </rom groupeid> <letifactive> zookeeper </ artifactid> </dependency> <dependency> <proupId> com.github.sgroschupf </prouprid> <prifactid> zkclient </ artifactid> </pedency> </pedencies> <Duild> <Glugins> <Glugin> <ProupId> org.apache.tomcat.maven </prôdId> <Artifactid> Tomcat7-Maven-Plugin </ ArtifactId> <FIFIGIGURATION> <port> 8081 </port> <path> / </ path> </ Configuration> </gingin> </gluns> </uild> spingmvc.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/s Chema / Context "XMLNS: MVC =" http://www.springframework.org/schema/mvc "xmlns: tx =" http: //www.springfrfrfr Amework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:dubbo="http://c ode.alibabatech.com/schema/dubbo"xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.xsdd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsdd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd "> < <MVC: annotation-Driven> </ MVC: Annotation-Driven> <anEn> <propriété name = "Prefix" value = "/ web-inf / jsp /"> </ propriété> <propriété name = "Suffix" value = ". JSP"> </ Probords> </ Bean> <! - Spécifiez le projet -> <Dubbo: Nom de l'application = " Center -> <Dubbo: Registry Protocol = "ZooKeeper" Address = "10.0.117.198:2181"> </ Dubbo: Registry> <! - Calling the Service -> <Bbo: Reference Interface = "com.itqf.service.itemService" id = "ItemService"> </ Dubbo: Reference> </ Beans>
Diagramme structurel:
5 Créez un printemps-commun
C'est un endroit que je dois utiliser pour placer des outils spécifiquement, qui est utilisé pour répondre à certains besoins publics; pom.xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance" xsi: schemalation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <ModelVersion> 4.0.0 </ Modelversion> <parent> <proupId> com.itqf </ groupeid> <Artifactid> Sing-Parent </ artifactid> <version> 0.0.1-snapshot </Dero version> </parent> <ArtefactId> Sing-Common </ ArfactId> <Dersoné> 0.0.1-Snapshot </DERNIERSE> <Dependances> <! - Time Operation Component -> <Dendency> <proupId> Joda-Time </proupId> <Artifactive> Joda-Time </Rifacatid> <version> $ {joda-time.version} </Dero version> </Dedency> <! - APACHE Composants -> <dependency> <proupId> org.apache.commons </rom grouped> <Artifactid> Commons-Lang3 </ Artifactid> <DERVIÈRE> $ {Commons-Lang3.Version} </ Version> </Dependency> <Dedency> <ProupId> org.apache.commons </proupId> <Artifact> <ProupId> org.apache.commons </proupId> <Artifact> Id> Commons-io </lefactive> <in version> $ {commons-io.version} </-version> </pependency> <dependency> <proupId> Commons-net </proncID> <Artifactid> Commons-net </retifactid> <version> $ {Commons-net.Version} </De version> </Dedency> <! - Jackson Json Process Toolkit -> <dependency> <proupId> com.fasterxml.jackson.core </prôdId> <ArtifactId> Jackson-Databind </retifactid> <Derences> $ {jackson.version} </preinte> </pependency> </pedencies> </propre>6 test
D'accord, ce projet pseudo-distribué a été construit. Le prochain point important est que le projet parent, le projet d'agrégation du Spring-Manager et le Spring-Common doivent être installés dans l'entrepôt local. Sinon, une erreur sera signalée lors du démarrage du projet et le projet parent ou d'autres projets ne peut être trouvé.
Dessin final:
Résumer:
Après plusieurs heures de travail acharné, je l'ai finalement construit. Le vieil homme qui allait être fatigué et explosé. S'il y a des erreurs ou des lacunes, veuillez être prêt à le faire.
Ce qui précède est tout le contenu de cet article. J'espère que cela sera utile à l'apprentissage de tous et j'espère que tout le monde soutiendra davantage Wulin.com.