本帖最后由 谷粒姐姐 于 2018-7-26 15:04 编辑
4.1.1 通用工具类模块 创建通用工具类模块 pinyougou-common 4.1.2 商家商品服务接口模块 创建 maven(jar)模块 pinyougou-sellergoods-interface , pom.xml 添加依赖 [AppleScript] 纯文本查看 复制代码 <dependencies> [AppleScript] 纯文本查看 复制代码 <dependency>[/size][/font][/align][font=微软雅黑][size=3]
<groupId>com.pinyougou</groupId>
<artifactId>pinyougou-pojo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
4.1.1 商家商品服务模块 创建 maven(war)模块 pinyougou-sellergoods-service ,pom.xml 引入依赖 [AppleScript] 纯文本查看 复制代码 <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> [AppleScript] 纯文本查看 复制代码 <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>com.alibaba</groupId>
[AppleScript] 纯文本查看 复制代码 <artifactId>dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
[AppleScript] 纯文本查看 复制代码 <groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.pinyougou</groupId>
<artifactId>pinyougou-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.pinyougou</groupId>
<artifactId>pinyougou-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.pinyougou</groupId>
<artifactId>pinyougou-sellergoods-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
[AppleScript] 纯文本查看 复制代码 </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 容器
[AppleScript] 纯文本查看 复制代码 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee [url=http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd]http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd[/url]"
version="2.5">
<!-- 加载 spring 容器 -->
<context-param>
[AppleScript] 纯文本查看 复制代码 <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 [AppleScript] 纯文本查看 复制代码 <?xml version="1.0" encoding="UTF-8"?>[/size][/font][/align][align=left][font=微软雅黑][size=3]<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.alibabatech.com/schema/dubbo" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans [url=http://www.springframework.org/schema/beans/spring-beans.xsd]http://www.springframework.org/schema/beans/spring-beans.xsd[/url]
[url=http://www.springframework.org/schema/mvc]http://www.springframework.org/schema/mvc[/url] [url=http://www.springframework.org/schema/mvc/spring-mvc.xsd]http://www.springframework.org/schema/mvc/spring-mvc.xsd[/url]
[url=http://code.alibabatech.com/schema/dubbo]http://code.alibabatech.com/schema/dubbo[/url] [url=http://code.alibabatech.com/schema/dubbo/dubbo.xsd]http://code.alibabatech.com/schema/dubbo/dubbo.xsd[/url]
[url=http://www.springframework.org/schema/context]http://www.springframework.org/schema/context[/url] [url=http://www.springframework.org/schema/context/spring-context.xsd]http://www.springframework.org/schema/context/spring-context.xsd[/url]"> [AppleScript] 纯文本查看 复制代码 <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.1.1 运营商管理后台 创建 maven(war)模块 pinyougou-manager-web , pom.xml 引入依赖 [AppleScript] 纯文本查看 复制代码 <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> [AppleScript] 纯文本查看 复制代码 <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>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
[AppleScript] 纯文本查看 复制代码 </dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
[AppleScript] 纯文本查看 复制代码 <artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.pinyougou</groupId>
<artifactId>pinyougou-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.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>
[AppleScript] 纯文本查看 复制代码 <artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/</path>
<port>9101</port>
</configuration>
</plugin>
</plugins>
</build> [AppleScript] 纯文本查看 复制代码 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
[url=http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd]http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd[/url]"
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> [AppleScript] 纯文本查看 复制代码 <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 [AppleScript] 纯文本查看 复制代码 <?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.alibabatech.com/schema/dubbo" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans [url=http://www.springframework.org/schema/beans/spring-beans.xsd]http://www.springframework.org/schema/beans/spring-beans.xsd[/url]
[url=http://www.springframework.org/schema/mvc]http://www.springframework.org/schema/mvc[/url] [url=http://www.springframework.org/schema/mvc/spring-mvc.xsd]http://www.springframework.org/schema/mvc/spring-mvc.xsd[/url]
[url=http://code.alibabatech.com/schema/dubbo]http://code.alibabatech.com/schema/dubbo[/url] [url=http://code.alibabatech.com/schema/dubbo/dubbo.xsd]http://code.alibabatech.com/schema/dubbo/dubbo.xsd[/url]
[url=http://www.springframework.org/schema/context]http://www.springframework.org/schema/context[/url] [url=http://www.springframework.org/schema/context/spring-context.xsd]http://www.springframework.org/schema/context/spring-context.xsd[/url]">
<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>[/size][/font][/align][align=left][font=微软雅黑][size=3][mw_shl_code=applescript,true]</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>
|