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

spring_boot pom.xml配置

程序员文章站 2022-03-18 15:38:34

<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.0</modelversion>
  <groupid>spring</groupid>
  <artifactid>spring-boot</artifactid>
  <packaging>war</packaging>
  <version>0.0.1-snapshot</version>
  <name>spring-boot maven webapp</name>
  <url>http://maven.apache.org</url>
   <!--  必须加,否则版本为null-->
   <parent>
        <groupid>org.springframework.boot</groupid>
        <artifactid>spring-boot-starter-parent</artifactid>
        <version>1.5.3.release</version>
        <relativepath />
    </parent>
  <properties>
<project.build.sourceencoding>utf-8</project.build.sourceencoding>
<spring.version>4.3.7.release</spring.version> 
  </properties>
  <dependencies>
  <!-- https://mvnrepository.com/artifact/junit/junit -->
<!-- <dependency>
   <groupid>junit</groupid>
   <artifactid>junit</artifactid>
   <version>4.12</version>
   <scope>test</scope>
</dependency> -->
   <!--  springboot配置-->
    <dependency>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-starter-web</artifactid>
        </dependency>
        <!-- springboot单元测试 -->
        <dependency>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-starter-test</artifactid>
            <scope>test</scope>
        </dependency>
<!--  springboot mybatis-->
        <dependency>
            <groupid>org.mybatis.spring.boot</groupid>
            <artifactid>mybatis-spring-boot-starter</artifactid>
            <version>1.1.1</version>
        </dependency>
        <!-- 热部署 -->
         <dependency>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-devtools</artifactid>
            <optional>true</optional>
        </dependency>
        <!-- thymeleaf模板引擎  该配置可先关掉!!!-->
    <!-- <dependency>
       <groupid>org.springframework.boot</groupid>
       <artifactid>spring-boot-starter-thymeleaf</artifactid>
   </dependency>-->
   <!--  配置这个才可以用html-->
<dependency>
   <groupid>net.sourceforge.nekohtml</groupid>
   <artifactid>nekohtml</artifactid>
   <version>1.9.22</version>
</dependency>
  <!-- 下面两个引入为了操作数据库 -->
           <dependency>
               <groupid>org.springframework.boot</groupid>
               <artifactid>spring-boot-starter-data-jpa</artifactid>
           </dependency>
           <dependency>
               <groupid>mysql</groupid>
               <artifactid>mysql-connector-java</artifactid>
           </dependency>
           <dependency>
             <groupid>org.springframework.boot</groupid>
              <artifactid>spring-boot-starter-aop</artifactid>
           </dependency>
        <dependency>
             <groupid>org.springframework.boot</groupid>
              <artifactid>spring-boot-starter-logging</artifactid>
           </dependency>
    
  </dependencies>
  <build>
    <plugins>
          <plugin>
                <groupid>org.springframework.boot</groupid>
                <artifactid>spring-boot-maven-plugin</artifactid>
                <dependencies>
                        <!-- 热部署 -->
                        <dependency>
                            <groupid>org.springframework</groupid>
                            <artifactid>springloaded</artifactid>
                            <version>1.2.6.release</version>
                        </dependency>
                    </dependencies>
            </plugin>
        </plugins>

  <!--  <artifactid>spring-boot</artifactid> 名字保持一致 -->
    <finalname>spring-boot</finalname>
  </build>
</project>  <artifactid>spring-boot</artifactid>

配置完成后,项目会报错,这时右键项目选择maven→update project;ok!

<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.0</modelversion>
    <groupid>spring_boot</groupid>
    <artifactid>spring_boot_day1</artifactid>
    <packaging>war</packaging>
    <version>0.0.1-snapshot</version>
    <name>spring_boot_day1 maven webapp</name>
    <url>http://maven.apache.org</url>
    <!--配置springboot所需的依赖 -->
    <parent>
        <groupid>org.springframework.boot</groupid>
        <artifactid>spring-boot-starter-parent</artifactid>
        <version>1.5.3.release</version>
    </parent>

    <dependencies>
        <!--springboot的相关启动 -->
        <dependency>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-starter-web</artifactid>
        </dependency>

        <!-- 热部署 -->
        <dependency>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-devtools</artifactid>
            <optional>true</optional>
            <scope>true</scope>
        </dependency>

        <!-- log4j -->
        <dependency>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-starter-log4j2</artifactid>
        </dependency>

        <!-- 使用jasper引擎解析jsp -->
        <dependency>
            <groupid>org.apache.tomcat.embed</groupid>
            <artifactid>tomcat-embed-jasper</artifactid>
            <scope>provided</scope>
        </dependency>

        <!-- jsp支持 -->
        <!-- servlet 依赖 -->
        <dependency>
            <groupid>javax.servlet.jsp.jstl</groupid>
            <artifactid>jstl-api</artifactid>
            <version>1.2</version>
            <exclusions>
                <exclusion>
                    <groupid>javax.servlet</groupid>
                    <artifactid>servlet-api</artifactid>
                </exclusion>
                <exclusion>
                    <groupid>javax.servlet.jsp</groupid>
                    <artifactid>jsp-api</artifactid>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupid>org.glassfish.web</groupid>
            <artifactid>jstl-impl</artifactid>
            <version>1.2</version>
            <exclusions>
                <exclusion>
                    <groupid>javax.servlet</groupid>
                    <artifactid>servlet-api</artifactid>
                </exclusion>
                <exclusion>
                    <groupid>javax.servlet.jsp</groupid>
                    <artifactid>jsp-api</artifactid>
                </exclusion>
                <exclusion>
                    <groupid>javax.servlet.jsp.jstl</groupid>
                    <artifactid>jstl-api</artifactid>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- <dependency> <groupid>javax.servlet</groupid> <artifactid>javax.servlet-api</artifactid> 
            <version>provided</version> </dependency> <dependency> <groupid>javax.servlet</groupid> 
            <artifactid>jstl</artifactid> </dependency> -->

        <!-- springboot 整合mybatis -->
        <!-- <dependency> <groupid>org.mybatis.spring.boot</groupid> <artifactid>mybatis-spring-boot-starter</artifactid> 
            <version>1.3.0</version> </dependency> -->

        <!-- mysql数据库 -->
        <dependency>
            <groupid>mysql</groupid>
            <artifactid>mysql-connector-java</artifactid>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupid>org.springframework.boot</groupid>
                <artifactid>spring-boot-maven-plugin</artifactid>
                <configuration>
                    <!-- 没有该配置,devtools不生效 -->
                    <fork>true</fork>
                </configuration>
            </plugin>
        </plugins>
        <finalname>spring_boot_day1</finalname>
    </build>
</project>