热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

分布式电商项目(01)--后台管理系统工程搭建

1.主要技术以及软件SSM、Redis、Solr、Mysql、Nginx、Intellij、Maven、Tomcat、SVN2.MAVENMAVEN中有三种工程类型:pom工程:

1.主要技术以及软件

SSM、Redis、Solr、Mysql、Nginx、Intellij、Maven、Tomcat、SVN

2.MAVEN

MAVEN中有三种工程类型:

  1. pom工程:用在父级工程或聚合工程中。用来做jar包的版本控制。
  2. war工程:将会打包成war,发布在服务器上的工程。如网站或服务。
  3. jar工程:将会打包成jar用作jar包使用。

3.后台管理系统工程搭建

后台管理系统的工程结构如下,其中parent为父工程,common,manager,pojo,mapper,service,web几个工程之间有依赖关系,如下图中的箭头所示

 

父工程应该是一个pom工程。在父工程中定义依赖的jar包的版本信息以及maven插件的版本。

3.1创建父工程

打开IDEA(Interllij idea),通过MAVEN创建一个新的工程。点击 File->New->Project.进入选择页面

然后选择左侧的maven,选择jdk版本,next

填写好 GroupId、ArtifactId、Version 并选择好项目目录后点击 next。

选择好工作路径之后,点击finish,到此,父工程就已创建完成了。

修改工程pom.xml文件

xml version="1.0" encoding="UTF-8"?>
<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.0modelVersion>

    <groupId>com.taotaogroupId>
    <artifactId>taotao-parentartifactId>
    <packaging>pompackaging>
    <version>1.0-SNAPSHOTversion>
    <modules>
        <module>taotaocommonmodule>
        <module>taotaomanagermodule>
    modules>

    
    <properties>
        <junit.version>4.12junit.version>
        <spring.version>4.1.3.RELEASEspring.version>
        <mybatis.version>3.2.8mybatis.version>
        <mybatis.spring.version>1.2.2mybatis.spring.version>
        <mybatis.paginator.version>1.2.15mybatis.paginator.version>
        <mysql.version>5.1.32mysql.version>
        <slf4j.version>1.6.4slf4j.version>
        <jackson.version>2.4.2jackson.version>
        <druid.version>1.0.9druid.version>
        <httpclient.version>4.3.5httpclient.version>
        <jstl.version>1.2jstl.version>
        <servlet-api.version>2.5servlet-api.version>
        <jsp-api.version>2.0jsp-api.version>
        <joda-time.version>2.5joda-time.version>
        <commons-lang3.version>3.3.2commons-lang3.version>
        <commons-io.version>1.3.2commons-io.version>
        <commons-net.version>3.3commons-net.version>
        <pagehelper.version>3.4.2-fixpagehelper.version>
        <jsqlparser.version>0.9.1jsqlparser.version>
        <commons-fileupload.version>1.3.1commons-fileupload.version>
        <jedis.version>2.7.2jedis.version>
        <solrj.version>4.10.3solrj.version>
    properties>
    
    <dependencyManagement>
        <dependencies>
            
            <dependency>
                <groupId>joda-timegroupId>
                <artifactId>joda-timeartifactId>
                <version>${joda-time.version}version>
            dependency>
            
            <dependency>
                <groupId>org.apache.commonsgroupId>
                <artifactId>commons-lang3artifactId>
                <version>${commons-lang3.version}version>
            dependency>
            <dependency>
                <groupId>org.apache.commonsgroupId>
                <artifactId>commons-ioartifactId>
                <version>${commons-io.version}version>
            dependency>
            <dependency>
                <groupId>commons-netgroupId>
                <artifactId>commons-netartifactId>
                <version>${commons-net.version}version>
            dependency>
            
            <dependency>
                <groupId>com.fasterxml.jackson.coregroupId>
                <artifactId>jackson-databindartifactId>
                <version>${jackson.version}version>
            dependency>
            
            <dependency>
                <groupId>org.apache.httpcomponentsgroupId>
                <artifactId>httpclientartifactId>
                <version>${httpclient.version}version>
            dependency>
            
            <dependency>
                <groupId>junitgroupId>
                <artifactId>junitartifactId>
                <version>${junit.version}version>
                <scope>testscope>
            dependency>
            
            <dependency>
                <groupId>org.slf4jgroupId>
                <artifactId>slf4j-log4j12artifactId>
                <version>${slf4j.version}version>
            dependency>
            
            <dependency>
                <groupId>org.mybatisgroupId>
                <artifactId>mybatisartifactId>
                <version>${mybatis.version}version>
            dependency>
            <dependency>
                <groupId>org.mybatisgroupId>
                <artifactId>mybatis-springartifactId>
                <version>${mybatis.spring.version}version>
            dependency>
            <dependency>
                <groupId>com.github.miemiedevgroupId>
                <artifactId>mybatis-paginatorartifactId>
                <version>${mybatis.paginator.version}version>
            dependency>
            <dependency>
                <groupId>com.github.pagehelpergroupId>
                <artifactId>pagehelperartifactId>
                <version>${pagehelper.version}version>
            dependency>
            
            <dependency>
                <groupId>mysqlgroupId>
                <artifactId>mysql-connector-javaartifactId>
                <version>${mysql.version}version>
            dependency>
            
            <dependency>
                <groupId>com.alibabagroupId>
                <artifactId>druidartifactId>
                <version>${druid.version}version>
            dependency>
            
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-contextartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-beansartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-webmvcartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-jdbcartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-aspectsartifactId>
                <version>${spring.version}version>
            dependency>
            
            <dependency>
                <groupId>jstlgroupId>
                <artifactId>jstlartifactId>
                <version>${jstl.version}version>
            dependency>
            <dependency>
                <groupId>javax.servletgroupId>
                <artifactId>servlet-apiartifactId>
                <version>${servlet-api.version}version>
                <scope>providedscope>
            dependency>
            <dependency>
                <groupId>javax.servletgroupId>
                <artifactId>jsp-apiartifactId>
                <version>${jsp-api.version}version>
                <scope>providedscope>
            dependency>
            
            <dependency>
                <groupId>commons-fileuploadgroupId>
                <artifactId>commons-fileuploadartifactId>
                <version>${commons-fileupload.version}version>
            dependency>
            
            <dependency>
                <groupId>redis.clientsgroupId>
                <artifactId>jedisartifactId>
                <version>${jedis.version}version>
            dependency>
            
            <dependency>
                <groupId>org.apache.solrgroupId>
                <artifactId>solr-solrjartifactId>
                <version>${solrj.version}version>
            dependency>
        dependencies>
    dependencyManagement>
    <build>
        <finalName>${project.artifactId}finalName>
        <plugins>
            
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-resources-pluginartifactId>
                <version>2.7version>
                <configuration>
                    <encoding>UTF-8encoding>
                configuration>
            plugin>
            
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>3.2version>
                <configuration>
                    <source>1.8source>
                    <target>1.8target>
                    <encoding>UTF-8encoding>
                configuration>
            plugin>
        plugins>
        <pluginManagement>
            <plugins>
                
                <plugin>
                    <groupId>org.apache.tomcat.mavengroupId>
                    <artifactId>tomcat7-maven-pluginartifactId>
                    <version>2.2version>
                plugin>
            plugins>
        pluginManagement>
    build>
project>
View Code

 

3.2创建common工程

点击file->new->module,进入下一个界面之后,选择左侧的maven,点击next

在ArtifactId输入想要的数据,点击next,进入下一个界面之后,点击finish,至此,common工程创建完成。

修改工程pom.xml文件

xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>taotao-parentartifactId>
        <groupId>com.taotaogroupId>
        <version>1.0-SNAPSHOTversion>
    parent>
    <modelVersion>4.0.0modelVersion>

    <groupId>com.taotaogroupId>
    <artifactId>taotao-commonartifactId>
    <version>1.0-SNAPSHOTversion>
    
    <dependencies>
        
        <dependency>
            <groupId>joda-timegroupId>
            <artifactId>joda-timeartifactId>
        dependency>
        
        <dependency>
            <groupId>org.apache.commonsgroupId>
            <artifactId>commons-lang3artifactId>
        dependency>
        <dependency>
            <groupId>org.apache.commonsgroupId>
            <artifactId>commons-ioartifactId>
        dependency>
        <dependency>
            <groupId>commons-netgroupId>
            <artifactId>commons-netartifactId>
        dependency>
        
        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-databindartifactId>
        dependency>
        
        <dependency>
            <groupId>org.apache.httpcomponentsgroupId>
            <artifactId>httpclientartifactId>
        dependency>
        
        <dependency>
            <groupId>junitgroupId>
            <artifactId>junitartifactId>
            <scope>testscope>
        dependency>
        
        <dependency>
            <groupId>org.slf4jgroupId>
            <artifactId>slf4j-log4j12artifactId>
        dependency>
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>servlet-apiartifactId>
            <scope>compilescope>
        dependency>

    dependencies>
project>
View Code

3.3创建聚合工程mannager

创建聚合工程的步骤和前面创建common工程的步骤是一样的,只是ArtifactId需要填入聚合工程名,然后修改聚合工程的pom.xml文件

xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>taotao-parentartifactId>
        <groupId>com.taotaogroupId>
        <version>1.0-SNAPSHOTversion>
    parent>
    <modelVersion>4.0.0modelVersion>
    <packaging>pompackaging>
    <modules>
        <module>taotaomanagerpojomodule>
        <module>taotaomanagermappermodule>
        <module>taotaomanagerservicemodule>
        <module>taotaomanagerwebmodule>
    modules>
    <artifactId>taotao-managerartifactId>

    <build>
        
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.mavengroupId>
                <artifactId>tomcat7-maven-pluginartifactId>
                <configuration>
                    <port>8080port>
                    <path>/path>
                configuration>
            plugin>
        plugins>
    build>

    
    <dependencies>
        <dependency>
            <groupId>com.taotaogroupId>
            <artifactId>taotao-commonartifactId>
            <version>1.0-SNAPSHOTversion>
        dependency>
    dependencies>

project>
View Code

3.4创建pojo、mapper、service工程

创建pojo、mapper、service工程的步骤和前面是一样的,Artifactid填入相应的工程名,然后修改相应工程的pom.xml

pojo工程的pom.xml

xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>taotao-managerartifactId>
        <groupId>com.taotaogroupId>
        <version>1.0-SNAPSHOTversion>
    parent>
    <modelVersion>4.0.0modelVersion>

    <artifactId>taotao-manager-pojoartifactId>


project>

mapper工程的pom.xml

xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>taotao-managerartifactId>
        <groupId>com.taotaogroupId>
        <version>1.0-SNAPSHOTversion>
    parent>
    <modelVersion>4.0.0modelVersion>

    <artifactId>taotao-manager-mapperartifactId>

    <build>
        <resources>
            <resource>
                <directory>src/main/javadirectory>
                <includes>
                    <include>**/*.propertiesinclude>
                    <include>**/*.xmlinclude>
                includes>
                <filtering>truefiltering>
            resource>
        resources>
    build>
    
    <dependencies>
        <dependency>
            <groupId>com.taotaogroupId>
            <artifactId>taotao-manager-pojoartifactId>
            <version>1.0-SNAPSHOTversion>
        dependency>
        
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatisartifactId>
        dependency>
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatis-springartifactId>
        dependency>
        <dependency>
            <groupId>com.github.miemiedevgroupId>
            <artifactId>mybatis-paginatorartifactId>
        dependency>
        <dependency>
            <groupId>com.github.pagehelpergroupId>
            <artifactId>pagehelperartifactId>
        dependency>
        
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
        dependency>
        
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>druidartifactId>
        dependency>
    dependencies>

project>
View Code

service工程的pom.xml

xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>taotao-managerartifactId>
        <groupId>com.taotaogroupId>
        <version>1.0-SNAPSHOTversion>
    parent>
    <modelVersion>4.0.0modelVersion>

    <artifactId>taotao-manager-serviceartifactId>

    
    <dependencies>
        <dependency>
            <groupId>com.taotaogroupId>
            <artifactId>taotao-manager-mapperartifactId>
            <version>1.0-SNAPSHOTversion>
        dependency>
        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-contextartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-beansartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webmvcartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-jdbcartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-aspectsartifactId>
        dependency>
    dependencies>

project>
View Code

3.5创建web工程

选择manager工程右键,new->module->maven

 

勾选 Web 骨架后点击 Next,填写好 ArtifactId 后点击 Next,然后选择自己的maven路径以及本地仓库的路径

然后为了提高加载速度,还需要点击右侧的+号添加一个属性,如下所示

修改项目的 pom.xml文件

xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <parent>
        <artifactId>taotao-managerartifactId>
        <groupId>com.taotaogroupId>
        <version>1.0-SNAPSHOTversion>
    parent>

    <modelVersion>4.0.0modelVersion>
    <packaging>warpackaging>

    <name>taotao-manager-webname>
    <artifactId>taotao-manager-webartifactId>

    <build>
        <plugins>
            <plugin>
                <groupId>org.mortbay.jettygroupId>
                <artifactId>maven-jetty-pluginartifactId>
                <version>6.1.7version>
                <configuration>
                    <connectors>
                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                            <port>8888port>
                            <maxIdleTime>30000maxIdleTime>
                        connector>
                    connectors>
                    <webAppSourceDirectory>${project.build.directory}/${pom.artifactId}-${pom.version}
                    webAppSourceDirectory>
                    <contextPath>/contextPath>
                configuration>
            plugin>
        plugins>

    build>

    
    <dependencies>
        <dependency>
            <groupId>com.taotaogroupId>
            <artifactId>taotao-manager-serviceartifactId>
            <version>1.0-SNAPSHOTversion>
        dependency>
        
        <dependency>
            <groupId>jstlgroupId>
            <artifactId>jstlartifactId>
        dependency>
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>servlet-apiartifactId>
            <scope>providedscope>
        dependency>
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>jsp-apiartifactId>
            <scope>providedscope>
        dependency>
        
        <dependency>
            <groupId>commons-fileuploadgroupId>
            <artifactId>commons-fileuploadartifactId>
        dependency>
    dependencies>

project>
View Code

至此,项目的后台管理系统的架构就搭建起来了,接下来就是框架的整合了

上面所述可能存在一些错误或者可以改进的地方,还望路过的大神不吝指教,感谢!!!

 


推荐阅读
author-avatar
昙檀禅潺_162
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有