快速搭建一个spring boot web项目

一,第一步,建立spring boot项目,

两种方法:

  1,使用spring boot tool工具快速生成spring boot项目

  2.创建一个简单的maven 项目,在pom.xml里面添加:

  添加父项目:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>    

  添加依赖:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

  添加构建插件:

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

  在入口类上添加@SpringBootApplication注解,在main方法里面如下启动spring boot:

public static void main(String[] args) {
        SpringApplication.run(DbclientApplication.class, args);
    }

二,第二步,添加web,在pom.xml中添加依赖:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

三,第三步,设置静态文件位置及配置;SpringBoot默认了静态文件的位置src/main/resources下的static目录;

  1.在src/main/resources下面的创建static文件夹,默认会访问里面的index.html文件。

  2,在src/main/resources下面application.properties中添加下面配置端口:

# 端口
server.port=8004

 

转载于:https://www.cnblogs.com/jayu/p/10650284.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值