Happymall商城实战——环境搭建与工具使用

开发环境简介

  1. JDK1.8
  2. IntelliJ IDEA 2017.2
  3. Tomcat8.0
  4. Maven 3.3.9
  5. MySQL 5.5+
  6. Mac OS or Win10
  7. Git and Github
  8. Chrome浏览器

开发环境搭建

  1. Java、IDEA、Tomcat、Maven、MySQL安装;
  2. 安装插件Mybatis-Plugin(神器,推荐,收费破解);
  3. Chrome浏览器安装插件Reslet Client和FE助手。

项目搭建

  1. 创建空Maven项目,配置Tomcat;
  2. 空项目提交至Github仓库;
  3. gitignore文件配置

    *.class
    
    
    #package file
    
    *.war
    *.ear
    
    
    #kdiff3 ignore
    
    *.orig
    
    
    #maven ignore
    
    target/
    
    
    #eclipse ignore
    
    .settings/
    .project
    .classpath
    
    
    #idea ignore
    
    .idea/
    /idea/
    *.ipr
    *.iml
    *.iws
    
    
    #temp file
    
    *.log
    *.cache
    *.diff
    *.patch
    *.tmp
    
    
    #system ignore
    
    .DS_Store
    Thumbs.db

Maven的pom文件配置

<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">
    <modelVersion>4.0.0modelVersion>
    <groupId>guo.pinggroupId>
    <artifactId>happymallartifactId>
    <packaging>warpackaging>
    <version>1.0-SNAPSHOTversion>
    <name>happymall Maven Webappname>
    <url>http://maven.apache.orgurl>

    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
        <maven.compiler.encoding>UTF-8maven.compiler.encoding>
        <org.springframework.version>4.0.0.RELEASEorg.springframework.version>
        <org.mybatis.version>3.4.1org.mybatis.version>
        <org.mybatis.spring.version>1.3.0org.mybatis.spring.version>
    properties>

    <dependencies>

        <dependency>
            <groupId>org.apache.tomcatgroupId>
            <artifactId>tomcat-servlet-apiartifactId>
            <version>8.0.47version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webmvcartifactId>
            <version>${org.springframework.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-oxmartifactId>
            <version>${org.springframework.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-jdbcartifactId>
            <version>${org.springframework.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-txartifactId>
            <version>${org.springframework.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-testartifactId>
            <version>${org.springframework.version}version>
        dependency>


        <dependency>
            <groupId>org.aspectjgroupId>
            <artifactId>aspectjweaverartifactId>
            <version>1.7.3version>
        dependency>

        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatis-springartifactId>
            <version>${org.mybatis.spring.version}version>
        dependency>
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatisartifactId>
            <version>${org.mybatis.version}version>
        dependency>

        <dependency>
            <groupId>org.aspectjgroupId>
            <artifactId>aspectjrtartifactId>
            <version>1.6.11version>
        dependency>

        <dependency>
            <groupId>org.codehaus.jacksongroupId>
            <artifactId>jackson-mapper-aslartifactId>
            <version>1.9.12version>
        dependency>

        <dependency>
            <groupId>commons-dbcpgroupId>
            <artifactId>commons-dbcpartifactId>
            <version>1.4version>
            
        dependency>


        <dependency>
            <groupId>ch.qos.logbackgroupId>
            <artifactId>logback-classicartifactId>
            <version>1.1.2version>
            <scope>compilescope>
        dependency>
        <dependency>
            <groupId>ch.qos.logbackgroupId>
            <artifactId>logback-coreartifactId>
            <version>1.1.2version>
            <scope>compilescope>
        dependency>

        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <version>5.1.6version>
        dependency>

        <dependency>
            <groupId>com.google.guavagroupId>
            <artifactId>guavaartifactId>
            <version>20.0version>
        dependency>


        <dependency>
            <groupId>org.apache.commonsgroupId>
            <artifactId>commons-lang3artifactId>
            <version>3.5version>
        dependency>


        <dependency>
            <groupId>commons-collectionsgroupId>
            <artifactId>commons-collectionsartifactId>
            <version>3.2.1version>
        dependency>


        <dependency>
            <groupId>junitgroupId>
            <artifactId>junitartifactId>
            <version>4.12version>
            
        dependency>

        <dependency>
            <groupId>joda-timegroupId>
            <artifactId>joda-timeartifactId>
            <version>2.3version>
        dependency>


        
        <dependency>
            <groupId>org.hashidsgroupId>
            <artifactId>hashidsartifactId>
            <version>1.0.1version>
        dependency>


        
        <dependency>
            <groupId>commons-netgroupId>
            <artifactId>commons-netartifactId>
            <version>3.1version>
        dependency>

        

        
        <dependency>
            <groupId>commons-fileuploadgroupId>
            <artifactId>commons-fileuploadartifactId>
            <version>1.2.2version>
        dependency>

        <dependency>
            <groupId>commons-iogroupId>
            <artifactId>commons-ioartifactId>
            <version>2.0.1version>
        dependency>




        

        <dependency>
            <groupId>com.github.pagehelpergroupId>
            <artifactId>pagehelperartifactId>
            <version>4.1.0version>
        dependency>

        <dependency>
            <groupId>com.github.miemiedevgroupId>
            <artifactId>mybatis-paginatorartifactId>
            <version>1.2.17version>
        dependency>

        <dependency>
            <groupId>com.github.jsqlparsergroupId>
            <artifactId>jsqlparserartifactId>
            <version>0.9.4version>
        dependency>


        
        <dependency>
            <groupId>commons-codecgroupId>
            <artifactId>commons-codecartifactId>
            <version>1.10version>
        dependency>
        <dependency>
            <groupId>commons-configurationgroupId>
            <artifactId>commons-configurationartifactId>
            <version>1.10version>
        dependency>
        <dependency>
            <groupId>commons-langgroupId>
            <artifactId>commons-langartifactId>
            <version>2.6version>
        dependency>
        <dependency>
            <groupId>commons-logginggroupId>
            <artifactId>commons-loggingartifactId>
            <version>1.1.1version>
        dependency>
        <dependency>
            <groupId>com.google.zxinggroupId>
            <artifactId>coreartifactId>
            <version>2.1version>
        dependency>
        <dependency>
            <groupId>com.google.code.gsongroupId>
            <artifactId>gsonartifactId>
            <version>2.3.1version>
        dependency>
        <dependency>
            <groupId>org.hamcrestgroupId>
            <artifactId>hamcrest-coreartifactId>
            <version>1.3version>
        dependency>

        <dependency>
            <groupId>redis.clientsgroupId>
            <artifactId>jedisartifactId>
            <version>2.9.0version>
        dependency>
    dependencies>


    <build>
        <finalName>happymallfinalName>
        <plugins>
            <plugin>
                <groupId>org.mybatis.generatorgroupId>
                <artifactId>mybatis-generator-maven-pluginartifactId>
                <version>1.3.2version>
                <configuration>
                    <verbose>trueverbose>
                    <overwrite>trueoverwrite>
                configuration>
            plugin>

            
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <configuration>
                    <source>1.8source>
                    <target>1.8target>
                    <encoding>UTF-8encoding>
                    <compilerArguments>
                        <extdirs>${project.basedir}/src/main/webapp/WEB-INF/libextdirs>
                    compilerArguments>
                configuration>
            plugin>
        plugins>
    build>
project>

项目包结构展示

Happymall商城实战——环境搭建与工具使用_第1张图片

项目配置

  1. mybatsi-gengerator反向工程;
  2. 使用分页插件mybatis-pagehelper;
  3. spring配置:applicationContext.xml、applicationContext-datasource.xml;
  4. Spring MVC配置:dispatcher-servlet.xml;
  5. 数据库properties文件:datasource.properties;
  6. 日志logback配置:logback.xml(主要是存放日志文件路径的更改);

时间戳问题

通过逆向工程生成的mapper.xml,其中时间戳是可以利用mysql的now()函数帮助我们自动填入时间。更改insert与update语句中的相关值即可。

项目地址

Github仓库:https://github.com/MrSorrow/happymall

你可能感兴趣的:(商城项目,java,javaee,电商,JavaEE)