Springboot 添加ymlproperties添加server.servlet.context-path

Springboot 添加ymlproperties添加server.servlet.context-path,第1张

简而言之:该 *** 作为项目访问路径整体添加一个前缀!

context-path即为 上下文路径 可以理解为项目路径

配置时:默认为/

若是配置/viplj 即变为

yml配置示例:

from lj 2022-03-01

有些用过springBoot工程的人总有疑惑,springBoot工程中是有一个application.yml配置文件的啊,其实application.yml的功能和application.properties是一样的,不过因为yml文件是树状结构,写起来有更好的层次感,更易于理解,所以很多人都选择了yml文件。

下面来说说将工程改成application.yml配置文件的详细步骤

第一步:在 application.properties 文件的同级目录下新建一个 application.yml 文件

第二步:添加application.yml文件中的配置如下:

server:

  port: 8088

spring:

    datasource:

        name: test

        url: jdbc:mysql://localhost:3306/test

        username: root

        password: xxx

        # 使用druid数据源

        type: com.alibaba.druid.pool.DruidDataSource

        driver-class-name: com.mysql.jdbc.Driver

        filters: stat

        maxActive: 20

        initialSize: 1

        maxWait: 60000

        minIdle: 1

        timeBetweenEvictionRunsMillis: 60000

        minEvictableIdleTimeMillis: 300000

        validationQuery: select 'x'

        testWhileIdle: true

        testOnBorrow: false

        testOnReturn: false

        poolPreparedStatements: true

        maxOpenPreparedStatements: 20

如图所示:

第三步:删除原有的application.properties文件

文件结构如图示:

第四步,重新编译maven工程

找到maven工具栏,双击clean,待执行完成后,双击install,执行完成则编译成功。

第四步,重启springboot项目

没有任何问题:

The End


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/7833725.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-10
下一篇2023-04-10

发表评论

登录后才能评论

评论列表(0条)

    保存