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

  1. 新建文件夹-IDEA打开

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

  1. 新建pom.xml

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

<?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

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

  • 支持成功

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

  1. 完善文件结构

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

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

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

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

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

<?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

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

  • deployment/+/artifact

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

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

  • 热部署

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

  1. 调试

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

完善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
  • 新建包,完善基本的三层架构

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

配置Spring、Log4j

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

  • 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

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

相关文章:

  • 2021-12-29
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-06-27
  • 2021-11-15
猜你喜欢
  • 2021-10-14
  • 2021-11-10
  • 2022-01-15
  • 2021-04-07
  • 2021-04-03
  • 2021-12-10
  • 2021-04-03
相关资源
相似解决方案