发表于: 2019-10-17 23:45:25

2 1009


今日完成

1.本地任务七代码拆分

1.1server

1.server.xml

<context:component-scan base-package="com.jnshu"/>

<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
   <property name="serviceName" value="loginService"/>
   <property name="service" ref="loginServiceImpl"/>
   <property name="serviceInterface" value="com.jnshu.service.LoginService"/>
   <property name="registryPort" value="1199"/>
</bean>

<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
   <property name="serviceName" value="excellentService"/>
   <property name="service" ref="excellentService"/>
   <property name="serviceInterface" value="com.jnshu.service.ExcellentService"/>
   <property name="registryPort" value="1199"/>
</bean>

<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
   <property name="serviceName" value="positionsService"/>
   <property name="service" ref="positionsServiceImpl"/>
   <property name="serviceInterface" value="com.jnshu.service.PositionsService"/>
   <property name="registryPort" value="1199"/>
</bean>

<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
   <property name="serviceName" value="userService"/>
   <property name="service" ref="userServiceImpl"/>
   <property name="serviceInterface" value="com.jnshu.service.UserService"/>
   <property name="registryPort" value="1199"/>
</bean>

2.publish

public class Publish {

public static void main(String[] args) {
    ApplicationContext ac = new ClassPathXmlApplicationContext("server.xml","spring-mybatis.xml");
   }
}

1.2client

1.client.xml

<context:component-scan base-package="com.jnshu"/>

<bean class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
   <property name="serviceUrl" value="rmi://localhost:1199/excellentService"/>
   <property name="serviceInterface" value="com.jnshu.service.ExcellentService"/>
</bean>

<bean class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
   <property name="serviceUrl" value="rmi://localhost:1199/loginService"/>
   <property name="serviceInterface" value="com.jnshu.service.LoginService"/>
</bean>


<bean class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
   <property name="serviceUrl" value="rmi://localhost:1199/positionsService"/>
   <property name="serviceInterface" value="com.jnshu.service.PositionsService"/>
</bean>


<bean class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
   <property name="serviceUrl" value="rmi://localhost:1199/userService"/>
   <property name="serviceInterface" value="com.jnshu.service.UserService"/>
</bean>

2.web.xml

<context-param>
 <param-name>contextConfigLocation</param-name>
 <param-value>
   classpath*:applicationContext-redis.xml
   classpath*:applicationContext-activemq.xml
   classpath*:client.xml
</param-value>
</context-param>


2.打包到服务器上运行

2.1打包

还是用任务一的没问题

<properties>
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   <maven.compiler.source>8</maven.compiler.source>
   <maven.compiler.target>8</maven.compiler.target>
</properties>


<build>
   <plugins>
       <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-shade-plugin</artifactId>
           <version> 1.7.1</version>
           <executions>
               <execution>
                   <phase>package</phase>
                   <goals>
                       <goal>shade</goal>
                   </goals>
                   <configuration>
                       <transformers>
                           <transformer
                                   implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                               <resource>META-INF/spring.handlers</resource>
                           </transformer>
                           <transformer
                                   implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                               <resource>META-INF/spring.schemas</resource>
                           </transformer>
                           <transformer
                                   implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                               <mainClass>com.jnshu.test.Publish</mainClass>
                           </transformer>
                       </transformers>
                   </configuration>
               </execution>
           </executions>
       </plugin>
   </plugins>
</build>

2.2步骤

不太好显示结果

先开启activemq、redis,再java -jar jar包名称,最后tomcat开启项目,正常开启

测试一下,把运行的jar包ctrl + c停下来,发现war包无法正常运行。


碰到问题

多个服务,挂掉一个没事的情况还不是很理解


明日计划

差一个部署多个server的,多个web就是nginx部署?完成任务8,开始任务9


启发


返回列表 返回列表
评论

    分享到