使用maven的方式创建Springboot项目

[复制链接]
发表于 2025-12-6 11:08:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
maven手动创建项目

创建空的maven项目

修改pom.xml



  • 修改parent
版本本身决定即可
  1.     <parent>
  2.         <groupId>org.springframework.boot</groupId>
  3.         <artifactId>spring-boot-starter-parent</artifactId>
  4.         <version>2.6.3</version>
  5.         <relativePath/>
  6.     </parent>
复制代码


  • 引入依靠
  1.         <dependency>
  2.             <groupId>org.springframework.boot</groupId>
  3.             <artifactId>spring-boot-starter-web</artifactId>
  4.         </dependency>
复制代码


  • 构建参数
  1.     <build>
  2.         <plugins>
  3.             <plugin>
  4.                 <groupId>org.springframework.boot</groupId>
  5.                 <artifactId>spring-boot-maven-plugin</artifactId>
  6.                 <configuration>
  7.                     <mainClass>com.te.TestWebApplication</mainClass>
  8.                 </configuration>
  9.             </plugin>
  10.         </plugins>
  11.     </build>
复制代码


  • 完备pom.xml
  1. <?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>
  2.         <groupId>org.springframework.boot</groupId>
  3.         <artifactId>spring-boot-starter-parent</artifactId>
  4.         <version>2.6.3</version>
  5.         <relativePath/>
  6.     </parent>
  7.     <packaging>jar</packaging>    <modelVersion>4.0.0</modelVersion>    <artifactId>forest_demo</artifactId>    <properties>        <maven.compiler.source>8</maven.compiler.source>        <maven.compiler.target>8</maven.compiler.target>    </properties>    <dependencies>        <dependency>
  8.             <groupId>org.springframework.boot</groupId>
  9.             <artifactId>spring-boot-starter-web</artifactId>
  10.         </dependency>
  11.     </dependencies>    <build>        <plugins>            <plugin>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-maven-plugin</artifactId>                <configuration>                    <mainClass>com.walker.forest.WalkerForestApplication</mainClass>                </configuration>            </plugin>        </plugins>    </build></project>
复制代码
Application创建

  1. package com.walker.forest;
  2. import org.springframework.boot.SpringApplication;
  3. import org.springframework.boot.autoconfigure.SpringBootApplication;
  4. @SpringBootApplication
  5. public class WalkerForestApplication {
  6.     public static void main(String[] args) {
  7.         SpringApplication.run(WalkerForestApplication.class, args);
  8.     }
  9. }
复制代码
之后可以本身创建application.yml大概application.properties

参考:https://blog.csdn.net/dhbfjh/article/details/127004818
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表