• Spring、Bootstrap简单练习(01/04)


    Spring、Bootstrap简单练习(01/04) - 创建项目

    项目创建流程

    1. 新建文件夹-IDEA打开

    image.png

    1. 新建pom.xml

    image.png

    <?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.hhhqqq</groupId>
        <artifactId>my-shop</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <packaging>war</packaging>
    
    </project>
    
    1. 添加Maven框架支持

    右击项目/添加框架支持/选择Maven

    image.png

    • 支持成功

    image.png

    1. 完善文件结构

    右键项目/新建/目录,添加以下三个目录

    image.png

    image.png

    1. 添加src/main/webapp
      • 添加WEB-INF
        • 添加web.xml
      • index.xml

    image.png

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
             version="4.0">
    
    </web-app>
    
    1. 配置tomcat
    • 添加
      运行配置/+/Tomcat Server/Local

    image.png

    • deployment/+/artifact

    image.png

    image.png

    • 热部署

    image.png

    1. 调试

    image.png

    完善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.hhhqqq</groupId>
        <artifactId>my-shop</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <packaging>war</packaging>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>4.3.17.RELEASE</version>
            </dependency>
    
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
            </dependency>
    
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>4.0.1</version>
            </dependency>
    
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>log4j-over-slf4j</artifactId>
                <version>1.7.25</version>
            </dependency>
        </dependencies>
    
    </project>
    

    完善架构结构

    • web资源目录 assets
    • 新建包,完善基本的三层架构

    image.png

    配置Spring、Log4j

    image.png

    • spring-context.xml

    很多命名方式

    • spring.xml
    • context.xml
    • springContext.xml
    • application.xml
    • applicationContext.xml
    • ...
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="
           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    
    </beans>
    
    • Log4j.properties
    log4j.rootLogger=INFO, console, file
    
    log4j.appender.console=org.apache.log4j.ConsoleAppender
    log4j.appender.console.layout=org.apache.log4j.PatternLayout
    log4j.appender.console.layout.ConversionPattern=%d %p [%c] - %m%n
    
    log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.file.File=logs/log.log
    log4j.appender.file.layout=org.apache.log4j.PatternLayout
    log4j.appender.A3.MaxFileSize=1024KB
    log4j.appender.A3.MaxBackupIndex=10
    log4j.appender.file.layout.ConversionPattern=%d %p [%c] - %m%n
    

    添加Bootstrap、jQuery

    image.png

  • 相关阅读:
    export和import实现模块化
    Net Core
    DockerCon 2016
    NET Core 构成体系
    Cloud Engine
    JVM内存结构
    Signalr
    Rabbit.Rpc
    遍历指定包名下所有的类(支持jar)(转)
    httpd的简单配置(转)
  • 原文地址:https://www.cnblogs.com/hhhqqq/p/12592734.html
Copyright © 2020-2023  润新知