1 verteilt
1.1 Was ist verteilt
1.2 Der Unterschied zwischen verteilten und Clustern
Es stellt sich heraus, dass es im kleinen Restaurant nur einen Koch gibt, der Gemüse schneidet, Gemüse wäscht, Zutaten zubereitet und sie alle rührt. Später gab es mehr Kunden und ein Koch in der Küche war zu beschäftigt, also stellte er einen anderen Koch ein. Beide Köche konnten die gleichen Gerichte kochen. Die Beziehung zwischen diesen beiden Köchen war ein Cluster. Um den Küchenchef auf das Kochen konzentrieren und das Beste aus den Gerichten machen, stellte er eine Beilage für das Schneiden von Gemüse, das Zubereiten von Geschirr und die Zubereitung von Zutaten ein. Die Beziehung zwischen dem Koch und der Beilage ist verteilt, und eine Beilage ist zu beschäftigt, sodass er eine Beilage anstellte, und die Beziehung zwischen den beiden Beilagen ist ein Cluster.
2. Erstellen Sie ein verteiltes Projekt
Zubereitungswerkzeuge: Eclipse, VMWarm, ausgestattet mit CentOS7-System, Zookeeper .... Das Wichtigste ist eine dreijährige ältere Maschine.
1 Erstellen Sie zunächst ein Maven -Projekt der übergeordneten Klasse, und die Verpackungsmethode ist POM.
Erstellen Sie ein übergeordnetes Klassen -Maven -Projekt in Eclipse, und die Verpackungsmethode ist POM. Warum ein übergeordnetes Klassen -Maven -Projekt erstellen? Da Sie dieses Maven -Projekt verwenden möchten, um verschiedene JAR -Paketversionen zu verwalten, können Sie dies tun, wenn die Unterklasse das JAR -Paket und die Elternklasse möchte. xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.itqf</groupId> <artifactId>sing-parent</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <!-- Define the version of all JAR-Pakete-> <Properties> <Junit.version> 4.12 </junit.version> <spring.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><Slf4j.version>1.6.4</slf4j.vesion 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> <Dubbo.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 </freemarker.version> <quartz.version> 2.2.2 </quartz.version> </Properties> <!-Verwalten Sie JAR-Pakete, die in allen Projekten verwendet werden, ohne reale Abhängigkeiten-> <DependyChmanagement> <Deponcies> <!-Zeitbetriebskomponente-> <Depopenty> <gruppe> Joda-Time </Groupid>
2 Erstellen Sie ein Maven -Aggregationsprojekt.
2.1 Erstellen Sie ein Maven -Aggregationsprojekt und erben Sie das übergeordnete Projekt.
Aggregation Engineering: Die Controller -Schicht, die Ansichtsschicht usw. im Projekt kann unabhängig zu einem Projekt geformt und schließlich in ein Projekt integriert werden, wenn es endlich ausgeführt wird.
pom.xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.itqf</groupId> <artifactId>sing-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>com.itqf</groupId> <artifactId> sing-Manager </artifactId> <version> 0.0.1-Snapshot </Version> <Packages> pom </packaging> <abhängigkeiten> <abhängig> <gruppe> com.itqf </Groupid> <artifactid> sing-common </artifactid> <version> 0.0.1-snapshot </fusion> <build><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><configuration><port>8083</port><path>/</path></configuration></plugin></plugins> </build> <modules> <Module> sing-Manager-pojo </modul> <module> sing-manager-interface </modul> <modul> sing-Manager-Service </modul> <modul> sing-Manager-Mapper </modul> </modules> </project>
2.2 Erstellen Sie ein Maven-Modul im Aggregationsprojekt und nennen Sie es Sping-Manager-Pojo (Entity Class Layer).
Pojo ist ein normales Glasformat und muss sich nicht auf das übergeordnete Projekt verlassen.
pom.xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance http://maven.apache.org/xsd/maven-4.0.0.xsd "> <modelVersion> 4.0.0 </modelversion> <sports> <gruppe> com.itqf </GroupId> <artifactid> sing-Manager </artifactid> <version> 0.0.1-Snapshot </selyfactId> </parent> <artifactid> sing-Manager-pojo </artifactid> </project>
2.3 Erstellen Sie ein Maven-Modul im Aggregationsprojekt und nennen Sie den Spring-Manager-Mapper (DAO-Schicht). Verlassen Sie sich in der Datei pom.xml auf pojo. Da die Mapper -Layer -Methode ein Entitätsklassenobjekt zurückgibt, muss Pojo verwendet werden.
Abhängigkeits -Jar -Pakete importieren.
xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance http://maven.apache.org/xsd/maven-4.0.0.xsd "> <modelVersion> 4.0.0 </modelversion> <sports> <gruppe> com.itqf </GroupId> <artifactid> sing-Manager </artifactid> <version> 0.0.1-Snapshot </selyfactId> </parent> <artifactid> sing-Manager-mapper </artifactid> <!-Abhängigkeit pojo-> <depeopcies> <De vorstellen> <gruppe> com.itqf </Groupid> <artifactID> sing-Manager-pojo </artifactid> <version> 0.0.1-Snapshot </Version> </vgl. -> <depeencing> <gruppe> org.mybatis </Groupid> <artifactId> mybatis </artifactId> <version> $ {mybatis.version} </Version> </abhängig> <depelziee> < GroupID> org.mybatis </GroupId> <artifactId> mybatis-pring </artifactId> <version> $ {mybatis.spring.version} </Version> </abhängig> <depelziee> <Gro upid> com.github.miemiedev </gruppeId> <artifactid> mybatis-paginator </artifactId> <version> $ {mybatis.paginator.version} </Version> </abhängig> <de pendent> <gruppe> com.github.pageHelper </Groupid> <artifactId> PageHelper </artifactId> <version> $ {pageHelper.version} </Version> </abhängig> <! MySQL-> <De vorstellen> <GroupId> Mysql </Groupid> <artifactId> Mysql-connector-Java </artifactid> <version> $ {mysql.version} </Version> </abhängig> <!-Verbindung Pool-> <De vor Ort> <gruppe> com.alibaba </GroupId> <artifactId> druid </artifactId> <version> $ {druid.version} </Version> </abhängig> </abhängiges> </project> 2.4 Erstellen Sie eine Spring-Manager-Schnittstelle (Schnittstelle) im Aggregationsprojekt und legen Sie alle Service-Schnittstellen in ein unabhängiges Projekt ein. Wenn der Rückgabewert der Methode in der Schnittstelle eine Entitätsklasse ist, ist Pojo erforderlich. Daher hängt es von Pojo xml in POM ab.
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance http://maven.apache.org/xsd/maven-4.0.0.xsd "> <modelVersion> 4.0.0 </modelversion> <sports> <gruppe> com.itqf </GroupId> <artifactid> sing-Manager </artifactid> <version> 0.0.1-Snapshot </selyfactId> </parent> <artifactId> sing-Manager-Schnittstelle </artifactId> <depeellodern> <abhängigkeit> <gruppe> com.itqf </Groupid> <artifactid> sing-Manager-pojo </artifactId> <version> 0.0.1-Snapshot </Version> </abhängig> </abhängig> </project> </project> </project> </project> </project> </project> </project>
2.5 Erstellen Sie Spring-Manager-Service (Schnittstellen-Implementierungsklasse) im Aggregationsprojekt. Die Verpackungsmethode ist Krieg
Da die Controller -Ebene von der Serviceschicht getrennt ist, sollte beim Ausführen und Starten der Controller und der Dienst mit Tomcat separat veröffentlicht werden, und alle im Aggregationsprojekt erforderlichen Konfigurationsdateien werden in den Dienst eingereicht, sodass alle Konfigurationsdateien geladen und integriert werden, wenn Tomcat gestartet wird.
Konfigurationsdatei
SqlMapConfig.xml
<?
db.properties
db.driver = com.mysql.jdbc.driverdb.url = jdbc: mysql: // localhost: 3306/taotao? CharakterCoding = utf-8db.username = rootdb.password = root
applicationContext-tx.xml
<? xmlns: p = "http://www.springframework.org/schema/p" xmlns: context = "http://www.springframework.org/s Chema/Kontext "XMLNS: mvc =" http://www.springframework.org/schema/mvc "xmlns: tx =" http: //www.springfr 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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/sping-mvc-4.g- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop--2.xsd 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 "> <bean id =" txManager "> </probiumsname =" datasource " id = "patchId" transaction-Manager = "TxManager"> <tx: Attribute> <tx: Methode name = "add*" Propagation = "Erforderlich"/> <tx: method name = "savagation*" Propagation = "Erforderlich"/> <tx: method name = "iNios Propagation = "Erforderlich"/> <tx: method name = "del*" Propagation = "Erforderlich"/> <tx: method name = "find*" Propagation = "Supports" schreibgeschützt = "true"/> <tx: method name = "get*" propagation = "Support" -Read> </> </tx: achtzeitabstände> </tx: rator: rator. Ratschläge-ref = "patchId" pointCut = "Ausführung (*com.itqf.service ..*.*(..))"/> </aop: config> </beans>
applicationContext-dao.xml
<? xmlns: p = "http://www.springframework.org/schema/p" xmlns: context = "http://www.spingframework.org/schema/context" xmlns: mvc = "http: //wwwwww.spingfr 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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/sping-mvc-4.g- 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: Property-Placeholder Ort =" ClassPath: Ressource/*. Eigenschaften "/> <Bean ID =" dataSource "> < name = "url" value = "$ {db.url}"> </property> <Eigenschaft name = "userername" value = "$ {db.username}"> </Eigenschaft> <Eigenschaft name = "password" value = "$ {db.password}" </bean> <bean> <Eigenschaft name = "dataSource" ref = "dataSource"> </Eigenschaft> <Eigenschaft name = "configLocation" value = "classPath: mybatis/sqlmapconfig.xml" applicationContext-service.xml
<? xmlns: p = "http://www.springframework.org/schema/p" xmlns: context = "http://www.spingframework.org/schema/context" xmlns: mvc = "http: //wwwwww.spingfr 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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/sping-mvc-4.g- 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: component-scan base-package =" com.itqf.service "> </context: component-scan> </beans> </beans>
pom.xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance http://maven.apache.org/xsd/maven-4.0.0.xsd "> <modelVersion> 4.0.0 </modelversion> <parent> <gruppe> com.qianfeng </gruppacid> <artifactid> sing-Manager </artifactid> <version> 0.0.1-snapshot </seltern </artifactid> <artifactId> sing-Manager-Service </artifactId> <packaging> Krieg </packaging> <abhängigkeiten> <Depopentcy> <gruppe> com.qianfeng </GroupId> <artifactId> sing-Manager-Schnitt- und -abhängigkeit </artifactId> <version> </gruppen> </villid> </vgl. <artifactid> sing-Manager-mapper </artifactId> <version> 0.0.1-Snapshot </Version> </abhängig> <!-Spring -> <depeencing> <gruppeId> org.springFramework </GroupId> <artifactId> Spring-Context </artifactID> <version> $ {Spring.version} </Version> </abhängig> <abhängigkeit> <gruppeId> org.springFramework </gruppen> <artifactid> fed> </artifactid> </gruppen> ash artifactid> </artifactid> </artifactid> </artifactid> Ring.Version} </Version> </abhängig> <depeopcy> <GroupId> org.springFramework </Groupid> <artifactId> Spring-webmvc </artifactID> <version> $ {Spring.version} </Version> </abhängig> <Deponcy> <gruppe-Spring-Spring-SpringFrame-FRAME </Groupid> <artifactId> org. JDBC </artifactId> <version> $ {Spring.version} </Version> </abhängig> <depelzus> <gruppe> org.springFramework </gruppen> <artifactId> Spring-Aspespects </artifactId> <version> $ {Spring.version} </Version> </abhängig> </abhängig> </filecho> </filecy> </stellung> </vgl rk</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> </abhängig> </project>Endgültige Ingenieurstruktur
3 Verwenden Sie Dubbo, um den Service zu veröffentlichen
Zuerst denken?
Mall -Websites wie Taobao und JD können sich nicht nur von der PC -Seite, sondern auch von der Handy -Seite anmelden. Wie wird es implementiert? Zwei Controller schreiben? Das ist definitiv nicht. Wer wird nichts zu tun haben, wenn Sie nichts zu tun haben? Dann erfordert dies die Verwendung von SOA (Service-orientierte Architektur). Wenn wir ein Projekt mit Distributed schreiben, werden sich viele Systeme anrufen. Wenn Sie hin und her rufen, ist die Codestruktur sehr verwirrend. Hier verwenden wir Dubbo, um das Problem zu vieler Publishing -Dienste zu lösen und uns nicht klar zu machen.
Was ist SOA
SOA ist eine Designmethode, die mehrere Dienste umfasst, und Dienste werden schließlich eine Reihe von Funktionen durch Zusammenarbeit bereitstellen. Ein Dienst existiert normalerweise in unabhängiger Form in einem Betriebssystemprozess. Dienste kommunizieren eher über das Netzwerk als über In-Process-Anrufe.
Beispielsweise haben Sie jetzt viele Dienste: Nachrichtendienste (Bereitstellung von Pressemitteilungen, Anzeigen, Änderungen, Löschen), Bestelldienste (Hinzufügung, Bestellveränderung, Bestellansicht, Bestelllöschung usw.) Finanzdienste (Umsatz, Ausgaben, Statistiken usw.) Mitarbeiterdienste (Neue Änderung, Anzeige, Beobachtung) Teilnahme (Anmeldung, Anmeldung, Anmeldung, Return, Return, Export, Export, Export, Export, Export, Statistik).
Dubbo
Was ist Dubbo (ein Management -Tool für Ressourcenplanung und Governance Center)
Mit der Entwicklung des Internets wurde das Ausmaß der Website -Anwendungen kontinuierlich erweitert, und herkömmliche vertikale Anwendungsarchitekturen können nicht mehr damit fertig werden. Verteilte Servicearchitekturen und mobile Computerarchitekturen sind unerlässlich. Ein Governance -System ist dringend erforderlich, um die geordnete Entwicklung der Architektur zu gewährleisten.
Einzelanwendungsarchitektur
Vertikale Anwendungsarchitektur
Verteilte Servicearchitektur
Flow Computing -Architektur
Konstruktion der Dubbo -Umgebung:
Rollenbeschreibung der Knoten:
Rufen Sie die Beziehungsbeschreibung an:
Hier kommen wir hauptsächlich zum Registrierungszentrum (Register) und nutzen Zookeeper, um als Registrierungszentrum zu fungieren.
Stellen Sie die Registrierung in der Linux -Umgebung, Zookeeper, bereit
Der erste Schritt besteht natürlich darin, die virtuelle Maschine einzuschalten, also werde ich es in CentOS7 machen.
Holen Sie sich ein zookeeper komprimiertes Paket online, meine ist Zookeeper-3.4.6.tar.gz
In /Opt -Verzeichnis einfügen und dekomprimieren. (Die JDK -Umgebung ist erforderlich. Wenn es keine JDK -Umgebung gibt, installieren Sie zuerst eine JDK)
Geben Sie das Zookeeper-3.4.6-Verzeichnis ein und erstellen Sie einen Ordner namens Data.
Umbenennen Sie zoo_sample.cfg im Verzeichnis ./conf in zoo.cfg Ändern Sie das Datenattribut in zoo.cfg: datadir =/opt/zookeeper-3.4.6/data
Schritt 7:
Beachten Sie, dass Sie nach Beginn von Zookeeper die Firewall ausschalten müssen !!! Das war's.
Fügen Sie der Service ApplicationContext-service.xml Konfigurationsdatei hinzu, um den Dienst zu veröffentlichen
<!-Verwenden Sie Dubbo, um den Service zu veröffentlichen-> <!-Geben Sie das Projekt an, in dem sich der Dienst befindet-> <Dubbo: Anwendungsname = "Sing-Manager"/> <!-Geben Sie an, dass die Registrierungsadresse die IP-Adresse in Linux plus der Portnummer und die Standard-Bestandszahl von Zookeeper ist 2181-> <Dubbo: Registry protocol = "Zookeper" Adress. > </Dubbo: Registry> <!-den Dienst einer bestimmten Port-Port-Port-Portnummer aussetzen, einen Port aus Wählen, der nicht besetzt ist-> <Dubbo: Protokoll name = "Dubbo" port = "20888"> </dubbo: Protocol> <! port = "2088"> </dubbo: protocol> <!-Ref ist der Name des vom Spring Container erstellten Serviceobjekts-> <Dubbo: Service Interface = "com.itqf.Service.ItemService" Ref = "itemServiceImpl" timeout = "6000000"> </dubbo: service> service> service> service>
Pakete in service pom.xml importieren
<!-Dubbo-verwandt-> <depeopcy> <gruppe> com.alibaba </Groupid> <artifactId> Dubbo </artifactid> <!-Abhängigkeiten ausschließen -> <clusions> <xclusion> <GroupId> org.springFramework </Groupid> <artifactId> Spring </artifactId> </exklusion> <xclusion> <gruppe> org.jboss.netty </Groupid> <artifactId> netty </artifactid> </exclusion> </exklusions >/Dependent> <Deponcy> <gruppe> org.apache.zookeeper </Groupid> <artifactId> Zookeeper </artifactid> </abhängig> <depeaponcy> <gruppe> com.github.sgroschupf </Groupid> <artifactId> Zkclient </artifactid> </</</</</</</</</</</cresce> </</</</croment>
4 Erstellen Sie einen Spring-Manager-Controller, der sich auf dem gleichen Niveau wie das aggregierte Projekt befindet. Abhängigkeiten importieren.
Der Konferenzer muss Dubbo verwenden, um auf den von der Service Layer veröffentlichten Dienst zuzugreifen. Um den Tomcat -Server zum Veröffentlichen zu verwenden, ist natürlich auch SpringMVC erforderlich.
xml
<abhängigkeiten> <!-Verlassen Sie sich nur auf die Service-Schnittstelle-> <Depopentcy> <gruppe> com.qianfeng </Groupid> <artifactId> sing-Manager-Schnittstelle </artifactid> <version> 0.0.1-Snapshot </Version> </abhängig> <!-Spring -> <depeencing> <gruppeId> org.springFramework </GroupId> <artifactId> Spring-Context </artifactID> <version> $ {Spring.version} </Version> </abhängig> <abhängigkeit> <gruppeId> org.springFramework </gruppen> <artifactid> fed> </artifactid> </gruppen> ash artifactid> </artifactid> </artifactid> </artifactid> Ring.Version} </Version> </abhängig> <depeopcy> <GroupId> org.springFramework </Groupid> <artifactId> Spring-webmvc </artifactID> <version> $ {Spring.version} </Version> </abhängig> <Deponcy> <gruppe-Spring-Spring-SpringFrame-FRAME </Groupid> <artifactId> org. JDBC </artifactId> <version> $ {Spring.version} </Version> </abhängig> <depelzus> <gruppe> org.springFramework </gruppen> <artifactId> Spring-Aspespects </artifactId> <version> $ {Spring.version} </Version> </abhängig> </abhängig> </filecho> </filecy> </stellung> </vgl rk</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> <!-- JSP-Related-> <Deponcy> <gruppe> JSTL </GroupID> <artifactId> JSTL </artifactID> </abhängig> <depeopcy> <gruppe> javax.servlet </Groupid> <artifactid> servlet-api </a rtifactId> <scope> bereitgestellt </scope> </abhängig> <depeopy> <gruppe> javax.servlet </Groupid> <artifactid> jsp-api </artifactId> <scope> bereitgestellt </scope> </abhängig> <!- Dubbo Related-> <De vor Ort> <gruppe> com.alibaba </Groupid> <artifactid> Dubbo </artifactid> <!-Abhängigkeiten ausschließen -> <clusions> <xclusion> <GroupId> org.springFramework </Groupid> <artifactId> Spring </artifactId> </exklusion> <xclusion> <gruppe> org.jboss.netty </Groupid> <artifactId> netty </artifactid> </exclusion> </exklusions >/abhängig> <depeopcy> <GroupId> org.apache.zookeeper </GroupId> <artifactId> Zookeeper </artifactid> </abhängig> <depecled> <GroupID> com.github.sgroschupf </gruppen> <artifactid> Zkclient </artifactid> </abhängig> </abhängig> <build> <PLUGINS> <PLUGIN> <GROPRECID> org.apache.tomcat.maven </GroupId> <artifactId> tomcat7-maven-plugin </artifactID> <Configuration> <Port> 8081 </port> <path>/</path> </configuration> </plugin> </plugins> </plugins> </bau> </bau> </plugins> </build> </bau> </build> </build> </bau> spingmvc.xml
<? xmlns: p = "http://www.springframework.org/schema/p" xmlns: context = "http://www.springframework.org/s Chema/Kontext "XMLNS: mvc =" http://www.springframework.org/schema/mvc "xmlns: tx =" http: //www.springfr 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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/sping-mvc-4.g- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop--2.xsd 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: conconent-scan-package =" com.itqf.controller "> </contexte: component-scan-clan> <MVC: Annotationsgetrieben> </mvc: Annotationsgetrieben> <bean> <Eigenschaft name = "prefix" value = "/web-inf/jsp/"> </property> <Eigenschaft name = "Suffix" value = ". JSP"> </Property> </bean> <!-Spezifische Project. Center-> <Dubbo: Registry Protocol = "Zookeeper" Adresse = "10.0.117.198:2181"> </Dubbo: Registry> <!-Der Service nennt-> <dubbo: reference interface = "com.itqf.service
Strukturdiagramm:
5 Erstellen Sie einen Frühlingskommon
Dies ist ein Ort, an den ich Tools speziell platzieren muss, mit denen einige öffentliche Bedürfnisse gestellt werden. pom.xml
<project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.itqf</groupId> <artifactId>sing-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>com.itqf</groupId> <artifactId> sing-common </artifactId> <version> 0.0.1-Snapshot </Version> <Deponcies> <!-Zeitoperationskomponente-> <Deponentcy> <gruppe> Joda-Zeit </Groupid> <artifactId> Joda-Time </artifactID> <version> $ {Joda-Time.version} </fusion> </apache apache $ {version} </fusion> </apache apache $ {version} </fusion> </apache apache $ {version} </file Komponenten-> <De vor Ort> <gruppe> org.apache.commons </Groupid> <artifactId> commons-Lang3 </artifactId> <version> $ {commons-Lang3.Version} </Version> </abhängig> <depapecy> <GroupId> org.apache.commons </GroupId> <artifact> <artifact Id>commons-io</artifactId><version>${commons-io.version}</version></dependency><dependency><groupId>commons-net</groupId><artifactId>commons-net</artifactId><version>${commons-net.version}</version></dependency><!-- Jackson Json Processing Toolkit-> <De vor Ort> <gruppe> com.fasterxml.jackson.core </Groupid> <artifactId> Jackson-Databind </artifactid> <version> $ {Jackson.version} </Version> </abhängig> </abhängigenzen> </project>6 Test
Okay, dieses pseudo-verteilte Projekt wurde gebaut. Der nächste wichtige Punkt ist, dass das übergeordnete Projekt, das Aggregationsprojekt des Spring-Managers und das Spring-Common im örtlichen Lagerhaus installiert werden müssen. Andernfalls wird ein Fehler gemeldet, wenn das Projekt gestartet wird und das übergeordnete Projekt oder andere Projekte nicht gefunden werden können.
Endgültige Zeichnung:
Zusammenfassen:
Nach einigen Stunden harter Arbeit habe ich es endlich gebaut. Der alte Mann, der müde und explodierte. Wenn es Fehler oder Mängel gibt, seien Sie bitte bereit.
Das obige ist der gesamte Inhalt dieses Artikels. Ich hoffe, es wird für das Lernen aller hilfreich sein und ich hoffe, jeder wird Wulin.com mehr unterstützen.