商城架构搭建

    项目工程结构及说明:

    

完整项目工程目录

    项目工程目录说明:

pinyougou-parent:               聚合工程

pinyougou-pojo:                  通用实体类层

pinyougou-dao:                    通用数据访问层

pinyougou-xxxxx-interface:   某服务层接口

pinyougou-xxxxx-service:      某服务层实现

pinyougou-xxxxx-web:          web工程


    创建数据库,引入sql文件,最终创建的数据库表结构如图所示:


    项目框架搭建:

        1.创建父工程 :

        创建Maven工程pinyougou-parent POMgroupId com.pinyougou ,artifactId pinyougou-parent , pom.xml中添加锁定版本信息dependencyManagementpluginManagement

<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>com.pinyougou</groupId>
  <artifactId>pinyougou-parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  
  <!-- 集中定义依赖版本号 -->
	<properties>
		<junit.version>4.12</junit.version>
		<spring.version>4.2.4.RELEASE</spring.version>
		<pagehelper.version>4.0.0</pagehelper.version>
		<servlet-api.version>2.5</servlet-api.version>
		<dubbo.version>2.8.4</dubbo.version>
		<zookeeper.version>3.4.12</zookeeper.version>
		<zkclient.version>0.1</zkclient.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>		
		<druid.version>1.0.9</druid.version>
		<commons-fileupload.version>1.3.1</commons-fileupload.version>
		<freemarker.version>2.3.23</freemarker.version>
		<activemq.version>5.11.2</activemq.version>
		<security.version>3.2.3.RELEASE</security.version>		
		<solrj.version>4.10.3</solrj.version>
		<ik.version>2012_u6</ik.version>		
	</properties>
	
	<dependencyManagement>
		<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>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-test</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<!-- dubbo相关 -->
			<dependency>
				<groupId>com.alibaba</groupId>
				<artifactId>dubbo</artifactId>
				<version>${dubbo.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.zookeeper</groupId>
				<artifactId>zookeeper</artifactId>
				<version>${zookeeper.version}</version>
			</dependency>
			<dependency>
				<groupId>com.github.sgroschupf</groupId>
				<artifactId>zkclient</artifactId>
				<version>${zkclient.version}</version>
			</dependency>
			<dependency>
				<groupId>junit</groupId>
				<artifactId>junit</artifactId>
				<version>4.9</version>
			</dependency>
			<dependency>
				<groupId>com.alibaba</groupId>
				<artifactId>fastjson</artifactId>
				<version>1.2.28</version>
			</dependency>
			<dependency>
				<groupId>javassist</groupId>
				<artifactId>javassist</artifactId>
				<version>3.11.0.GA</version>
			</dependency>
			<dependency>
			    <groupId>commons-codec</groupId>
			    <artifactId>commons-codec</artifactId>
			    <version>1.10</version>
			</dependency>
			<dependency>
				<groupId>javax.servlet</groupId>
				<artifactId>servlet-api</artifactId>
				<version>2.5</version>
				<scope>provided</scope>
			</dependency>
			<dependency>
			    <groupId>com.github.pagehelper</groupId>
			    <artifactId>pagehelper</artifactId>
			    <version>${pagehelper.version}</version>
			</dependency>		
		  	<!-- Mybatis -->
			<dependency>
				<groupId>org.mybatis</groupId>
				<artifactId>mybatis</artifactId>
				<version>${mybatis.version}</version>
			</dependency>
			<dependency>
				<groupId>org.mybatis</groupId>
				<artifactId>mybatis-spring</artifactId>
				<version>${mybatis.spring.version}</version>
			</dependency>
			<dependency>
				<groupId>com.github.miemiedev</groupId>
				<artifactId>mybatis-paginator</artifactId>
				<version>${mybatis.paginator.version}</version>
			</dependency>		
			<!-- MySql -->
			<dependency>
				<groupId>mysql</groupId>
				<artifactId>mysql-connector-java</artifactId>
				<version>${mysql.version}</version>
			</dependency>
			<!-- 连接池 -->
			<dependency>
				<groupId>com.alibaba</groupId>
				<artifactId>druid</artifactId>
				<version>${druid.version}</version>
			</dependency>		
			<dependency>
			    <groupId>org.csource.fastdfs</groupId>
			    <artifactId>fastdfs</artifactId>
			    <version>1.2</version>
			</dependency>
			<!-- 文件上传组件 -->
			<dependency>
				<groupId>commons-fileupload</groupId>
				<artifactId>commons-fileupload</artifactId>
				<version>${commons-fileupload.version}</version>
			</dependency>		
			<!-- 缓存 -->
			<dependency> 
			  <groupId>redis.clients</groupId> 
			  <artifactId>jedis</artifactId> 
			  <version>2.8.1</version> 
			</dependency> 
			<dependency> 
			  <groupId>org.springframework.data</groupId> 
			  <artifactId>spring-data-redis</artifactId> 
			  <version>1.7.2.RELEASE</version> 
			</dependency>		
			<dependency>
				<groupId>org.freemarker</groupId>
				<artifactId>freemarker</artifactId>
				<version>${freemarker.version}</version>
			</dependency>		
			<dependency>
				<groupId>org.apache.activemq</groupId>
				<artifactId>activemq-all</artifactId>
				<version>${activemq.version}</version>
			</dependency>
			<!-- 身份验证 -->
			<dependency>
				<groupId>org.springframework.security</groupId>
				<artifactId>spring-security-web</artifactId>
				<version>4.1.0.RELEASE</version>
			</dependency>
			<dependency>
				<groupId>org.springframework.security</groupId>
				<artifactId>spring-security-config</artifactId>
				<version>4.1.0.RELEASE</version>
			</dependency>		
			<dependency>
			    <groupId>com.github.penggle</groupId>
			    <artifactId>kaptcha</artifactId>
			    <version>2.3.2</version>
			    <exclusions>
			    	<exclusion>
			    		<groupId>javax.servlet</groupId>
	      				<artifactId>javax.servlet-api</artifactId>
			    	</exclusion>
			    </exclusions>
			</dependency>		
			<dependency>  
		        <groupId>org.springframework.security</groupId>  
		        <artifactId>spring-security-cas</artifactId>  
		        <version>4.1.0.RELEASE</version>  
		    </dependency>  
		    <dependency>  
		        <groupId>org.jasig.cas.client</groupId>  
		        <artifactId>cas-client-core</artifactId>  
		        <version>3.3.3</version>  
		        <!-- 排除log4j包冲突 -->  
		        <exclusions>  
		            <exclusion>  
		                <groupId>org.slf4j</groupId>  
		                <artifactId>log4j-over-slf4j</artifactId>  
		            </exclusion>  
		        </exclusions>  
		    </dependency> 	    
		    <!-- solr客户端 -->
			<dependency>
				<groupId>org.apache.solr</groupId>
				<artifactId>solr-solrj</artifactId>
				<version>${solrj.version}</version>
			</dependency>
			<dependency>
				<groupId>com.janeluo</groupId>
				<artifactId>ikanalyzer</artifactId>
				<version>${ik.version}</version>
			</dependency>	
	  		<dependency>
	  			<groupId>org.apache.httpcomponents</groupId>
	  			<artifactId>httpcore</artifactId>
	  			<version>4.4.4</version>
	  		</dependency>  		
	  		<dependency>
	  			<groupId>org.apache.httpcomponents</groupId>
	  			<artifactId>httpclient</artifactId>
	  			<version>4.5.3</version>
	  		</dependency>
	  		<dependency>
	  			<groupId>dom4j</groupId>
	  			<artifactId>dom4j</artifactId>
	  			<version>1.6.1</version>
	  		</dependency>  		
	  		<dependency>  
	            <groupId>xml-apis</groupId>  
	            <artifactId>xml-apis</artifactId>  
	            <version>1.4.01</version>  
	        </dependency> 		
		</dependencies>	
	
	</dependencyManagement>
	

	
	<build>
		
		<plugins>			
			<!-- java编译插件 -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.2</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>

		</plugins>
	
	</build>
	<modules>
		<module>pinyougou-pojo</module>
		<module>pinyougou-dao</module>
		<module>pinyougou-common</module>
		<module>pinyougou-sellergoods-interface</module>
		<module>pinyougou-sellergoods-service</module>
		<module>pinyougou-manage-web</module>
		<module>pinyougou-shop-web</module>
	</modules>
</project>
父工程POM文件

2.创建通用实体类模块:

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

3.创建通用数据访问模块:

        创建通用数据访问模块pinyougou-dao .添加Mybatis、PageHelper、MySQL、德鲁伊数据库连接池以及pinyougou-pojo依赖。

<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>
  <parent>
    <groupId>com.pinyougou</groupId>
    <artifactId>pinyougou-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>pinyougou-dao</artifactId>
  
  <dependencies>

  	<dependency>
	    <groupId>com.github.pagehelper</groupId>
	    <artifactId>pagehelper</artifactId>	   
	</dependency>		
  	<!-- Mybatis -->
	<dependency>
		<groupId>org.mybatis</groupId>
		<artifactId>mybatis</artifactId>		
	</dependency>
	<dependency>
		<groupId>org.mybatis</groupId>
		<artifactId>mybatis-spring</artifactId>		
	</dependency>
	<dependency>
		<groupId>com.github.miemiedev</groupId>
		<artifactId>mybatis-paginator</artifactId>		
	</dependency>		
	<!-- MySql -->
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>		
	</dependency>
	<!-- 连接池 -->
	<dependency>
		<groupId>com.alibaba</groupId>
		<artifactId>druid</artifactId>		
	</dependency>

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

添加依赖

4.创建通用工具类模块:

        创建通用工具类模块pinyougou-common,不需要引入额外的依赖。

5.创建商家商品服务接口模块:

        创建mavenjar)模块pinyougou-sellergoods-interface  , 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>
  <parent>
    <groupId>com.pinyougou</groupId>
    <artifactId>pinyougou-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>pinyougou-sellergoods-interface</artifactId>
  <dependencies>
  	<dependency>
  		<groupId>com.pinyougou</groupId>
  		<artifactId>pinyougou-pojo</artifactId>
  		<version>0.0.1-SNAPSHOT</version>
  	</dependency>
  </dependencies>
</project>
添加依赖

6.创建商家商品服务模块:

        

创建maven(war)模块pinyougou-sellergoods-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>
  <parent>
    <groupId>com.pinyougou</groupId>
    <artifactId>pinyougou-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>pinyougou-sellergoods-service</artifactId>
  <packaging>war</packaging>
  
  <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>com.alibaba</groupId>
		<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>
	    <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-sellergoods-interface</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-pojo</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</dependency>
  </dependencies>
  
  <build>  
	  <plugins>	     
	      <plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.2</version>
				<configuration>
					<!-- 指定端口 -->
					<port>9001</port>
					<!-- 请求路径 -->
					<path>/</path>
				</configuration>
	  	  </plugin>
	  </plugins>  
    </build>
</project>
添加依赖

  7.创建运营商后台管理模块:

          创建maven(war)模块pinyougou-manager-web   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>
  <parent>
    <groupId>com.pinyougou</groupId>
    <artifactId>pinyougou-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>pinyougou-manage-web</artifactId>
  <packaging>war</packaging>
  
  <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>com.alibaba</groupId>
		<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>
	    <groupId>commons-codec</groupId>
	    <artifactId>commons-codec</artifactId>
	</dependency>
	<dependency>
		<groupId>javax.servlet</groupId>
		<artifactId>servlet-api</artifactId>		
		<scope>provided</scope>
	</dependency>
	
	<!-- 引入spring-security -->
	<dependency>
		<groupId>org.springframework.security</groupId>
		<artifactId>spring-security-web</artifactId>
	</dependency>

	<dependency>
		<groupId>org.springframework.security</groupId>
		<artifactId>spring-security-config</artifactId>	
	</dependency>

	<dependency>
		<groupId>com.pinyougou</groupId>
		<artifactId>pinyougou-sellergoods-interface</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</dependency>
  </dependencies>
  
  
    <build>  
	  <plugins>
	      <plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.2</version>
				<configuration>
					<!-- 指定端口 -->
					<port>9101</port>
					<!-- 请求路径 -->
					<path>/</path>
				</configuration>
	  	  </plugin>
	  </plugins>  
    </build>
    
</project>
添加依赖

8.创建商家后台管理模块:

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

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

(2)在springmvc.xml配置文件中引入dubbo服务

<?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 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.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.xsd">
    <context:property-placeholder location="classpath:config/application.properties" />
	
	<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-shop-web" />
	<dubbo:registry address="zookeeper://192.168.25.128:2181"/>
	<dubbo:annotation package="com.pinyougou.shop.controller" />  	

</beans>


实体类和数据访问层模块代码编写:

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

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

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

        3.将com.pinyougou.pojo包下的每个实体类实现Serializable序列化接口



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值