欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

分布式项目--后台管理系统工程搭建

程序员文章站 2022-05-03 22:57:57
1.主要技术以及软件 SSM、Redis、Solr、Mysql、Nginx、Intellij、Maven、Tomcat、SVN 2.MAVEN MAVEN中有三种工程类型: 3.后台管理系统工程搭建 后台管理系统的工程结构如下,其中parent为父工程,common,manager,pojo,map ......

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.0</modelversion>

    <groupid>com.taotao</groupid>
    <artifactid>taotao-parent</artifactid>
    <packaging>pom</packaging>
    <version>1.0-snapshot</version>
    <modules>
        <module>taotaocommon</module>
        <module>taotaomanager</module>
    </modules>

    <!-- 集中定义依赖版本号 -->
    <properties>
        <junit.version>4.12</junit.version>
        <spring.version>4.1.3.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.version>
        <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.version>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>
    </properties>
    <!-- 只定义依赖的版本,并不实际依赖 -->
    <dependencymanagement>
        <dependencies>
            <!-- 时间操作组件 -->
            <dependency>
                <groupid>joda-time</groupid>
                <artifactid>joda-time</artifactid>
                <version>${joda-time.version}</version>
            </dependency>
            <!-- apache工具组件 -->
            <dependency>
                <groupid>org.apache.commons</groupid>
                <artifactid>commons-lang3</artifactid>
                <version>${commons-lang3.version}</version>
            </dependency>
            <dependency>
                <groupid>org.apache.commons</groupid>
                <artifactid>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处理工具包 -->
            <dependency>
                <groupid>com.fasterxml.jackson.core</groupid>
                <artifactid>jackson-databind</artifactid>
                <version>${jackson.version}</version>
            </dependency>
            <!-- httpclient -->
            <dependency>
                <groupid>org.apache.httpcomponents</groupid>
                <artifactid>httpclient</artifactid>
                <version>${httpclient.version}</version>
            </dependency>
            <!-- 单元测试 -->
            <dependency>
                <groupid>junit</groupid>
                <artifactid>junit</artifactid>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <!-- 日志处理 -->
            <dependency>
                <groupid>org.slf4j</groupid>
                <artifactid>slf4j-log4j12</artifactid>
                <version>${slf4j.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>
            <dependency>
                <groupid>com.github.pagehelper</groupid>
                <artifactid>pagehelper</artifactid>
                <version>${pagehelper.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>
            <!-- 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>
            <!-- jsp相关 -->
            <dependency>
                <groupid>jstl</groupid>
                <artifactid>jstl</artifactid>
                <version>${jstl.version}</version>
            </dependency>
            <dependency>
                <groupid>javax.servlet</groupid>
                <artifactid>servlet-api</artifactid>
                <version>${servlet-api.version}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupid>javax.servlet</groupid>
                <artifactid>jsp-api</artifactid>
                <version>${jsp-api.version}</version>
                <scope>provided</scope>
            </dependency>
            <!-- 文件上传组件 -->
            <dependency>
                <groupid>commons-fileupload</groupid>
                <artifactid>commons-fileupload</artifactid>
                <version>${commons-fileupload.version}</version>
            </dependency>
            <!-- redis客户端 -->
            <dependency>
                <groupid>redis.clients</groupid>
                <artifactid>jedis</artifactid>
                <version>${jedis.version}</version>
            </dependency>
            <!-- solr客户端 -->
            <dependency>
                <groupid>org.apache.solr</groupid>
                <artifactid>solr-solrj</artifactid>
                <version>${solrj.version}</version>
            </dependency>
        </dependencies>
    </dependencymanagement>
    <build>
        <finalname>${project.artifactid}</finalname>
        <plugins>
            <!-- 资源文件拷贝插件 -->
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-resources-plugin</artifactid>
                <version>2.7</version>
                <configuration>
                    <encoding>utf-8</encoding>
                </configuration>
            </plugin>
            <!-- java编译插件 -->
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-compiler-plugin</artifactid>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>utf-8</encoding>
                </configuration>
            </plugin>
        </plugins>
        <pluginmanagement>
            <plugins>
                <!-- 配置tomcat插件 -->
                <plugin>
                    <groupid>org.apache.tomcat.maven</groupid>
                    <artifactid>tomcat7-maven-plugin</artifactid>
                    <version>2.2</version>
                </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-parent</artifactid>
        <groupid>com.taotao</groupid>
        <version>1.0-snapshot</version>
    </parent>
    <modelversion>4.0.0</modelversion>

    <groupid>com.taotao</groupid>
    <artifactid>taotao-common</artifactid>
    <version>1.0-snapshot</version>
    <!-- jar包的依赖 -->
    <dependencies>
        <!-- 时间操作组件 -->
        <dependency>
            <groupid>joda-time</groupid>
            <artifactid>joda-time</artifactid>
        </dependency>
        <!-- apache工具组件 -->
        <dependency>
            <groupid>org.apache.commons</groupid>
            <artifactid>commons-lang3</artifactid>
        </dependency>
        <dependency>
            <groupid>org.apache.commons</groupid>
            <artifactid>commons-io</artifactid>
        </dependency>
        <dependency>
            <groupid>commons-net</groupid>
            <artifactid>commons-net</artifactid>
        </dependency>
        <!-- jackson json处理工具包 -->
        <dependency>
            <groupid>com.fasterxml.jackson.core</groupid>
            <artifactid>jackson-databind</artifactid>
        </dependency>
        <!-- httpclient -->
        <dependency>
            <groupid>org.apache.httpcomponents</groupid>
            <artifactid>httpclient</artifactid>
        </dependency>
        <!-- 单元测试 -->
        <dependency>
            <groupid>junit</groupid>
            <artifactid>junit</artifactid>
            <scope>test</scope>
        </dependency>
        <!-- 日志处理 -->
        <dependency>
            <groupid>org.slf4j</groupid>
            <artifactid>slf4j-log4j12</artifactid>
        </dependency>
        <dependency>
            <groupid>javax.servlet</groupid>
            <artifactid>servlet-api</artifactid>
            <scope>compile</scope>
        </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-parent</artifactid>
        <groupid>com.taotao</groupid>
        <version>1.0-snapshot</version>
    </parent>
    <modelversion>4.0.0</modelversion>
    <packaging>pom</packaging>
    <modules>
        <module>taotaomanagerpojo</module>
        <module>taotaomanagermapper</module>
        <module>taotaomanagerservice</module>
        <module>taotaomanagerweb</module>
    </modules>
    <artifactid>taotao-manager</artifactid>

    <build>
        <!-- 配置插件 -->
        <plugins>
            <plugin>
                <groupid>org.apache.tomcat.maven</groupid>
                <artifactid>tomcat7-maven-plugin</artifactid>
                <configuration>
                    <port>8080</port>
                    <path>/</path>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!--依赖管理-->
    <dependencies>
        <dependency>
            <groupid>com.taotao</groupid>
            <artifactid>taotao-common</artifactid>
            <version>1.0-snapshot</version>
        </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-manager</artifactid>
        <groupid>com.taotao</groupid>
        <version>1.0-snapshot</version>
    </parent>
    <modelversion>4.0.0</modelversion>

    <artifactid>taotao-manager-pojo</artifactid>


</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-manager</artifactid>
        <groupid>com.taotao</groupid>
        <version>1.0-snapshot</version>
    </parent>
    <modelversion>4.0.0</modelversion>

    <artifactid>taotao-manager-mapper</artifactid>

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
    <!-- 依赖管理 -->
    <dependencies>
        <dependency>
            <groupid>com.taotao</groupid>
            <artifactid>taotao-manager-pojo</artifactid>
            <version>1.0-snapshot</version>
        </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>
        <dependency>
            <groupid>com.github.pagehelper</groupid>
            <artifactid>pagehelper</artifactid>
        </dependency>
        <!-- mysql -->
        <dependency>
            <groupid>mysql</groupid>
            <artifactid>mysql-connector-java</artifactid>
        </dependency>
        <!-- 连接池 -->
        <dependency>
            <groupid>com.alibaba</groupid>
            <artifactid>druid</artifactid>
        </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-manager</artifactid>
        <groupid>com.taotao</groupid>
        <version>1.0-snapshot</version>
    </parent>
    <modelversion>4.0.0</modelversion>

    <artifactid>taotao-manager-service</artifactid>

    <!-- 依赖管理 -->
    <dependencies>
        <dependency>
            <groupid>com.taotao</groupid>
            <artifactid>taotao-manager-mapper</artifactid>
            <version>1.0-snapshot</version>
        </dependency>
        <!-- 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>
    </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-manager</artifactid>
        <groupid>com.taotao</groupid>
        <version>1.0-snapshot</version>
    </parent>

    <modelversion>4.0.0</modelversion>
    <packaging>war</packaging>

    <name>taotao-manager-web</name>
    <artifactid>taotao-manager-web</artifactid>

    <build>
        <plugins>
            <plugin>
                <groupid>org.mortbay.jetty</groupid>
                <artifactid>maven-jetty-plugin</artifactid>
                <version>6.1.7</version>
                <configuration>
                    <connectors>
                        <connector implementation="org.mortbay.jetty.nio.selectchannelconnector">
                            <port>8888</port>
                            <maxidletime>30000</maxidletime>
                        </connector>
                    </connectors>
                    <webappsourcedirectory>${project.build.directory}/${pom.artifactid}-${pom.version}
                    </webappsourcedirectory>
                    <contextpath>/</contextpath>
                </configuration>
            </plugin>
        </plugins>

    </build>

    <!-- 依赖管理 -->
    <dependencies>
        <dependency>
            <groupid>com.taotao</groupid>
            <artifactid>taotao-manager-service</artifactid>
            <version>1.0-snapshot</version>
        </dependency>
        <!-- jsp相关 -->
        <dependency>
            <groupid>jstl</groupid>
            <artifactid>jstl</artifactid>
        </dependency>
        <dependency>
            <groupid>javax.servlet</groupid>
            <artifactid>servlet-api</artifactid>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupid>javax.servlet</groupid>
            <artifactid>jsp-api</artifactid>
            <scope>provided</scope>
        </dependency>
        <!-- 文件上传组件 -->
        <dependency>
            <groupid>commons-fileupload</groupid>
            <artifactid>commons-fileupload</artifactid>
        </dependency>
    </dependencies>

</project>
view code

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

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