Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problems encountered by the SpringBoot configuration file application.yml

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to solve the problems encountered in the SpringBoot configuration file application.yml. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Configuration file application.yml encountered pit 1. The first pit, the original code username:rootpassword:123456

Project startup reported the following exception:

Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning a simple key

The root cause of the problem: use a colon between the application.yml file key and value pair: separated, and there is a space between the colon and the value

What the above exception produces is the key followed by the sign followed by the value, leaving no space.

Solution.

Colon: leave a space behind before writing the value

two。 The second pit, the original code, see the following figure

The following exceptions are reported after the project is started:

Caused by: org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here

Or

Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing a block mapping

Expected, but found''

In 'reader', line 11, column 3:

Jpa:

The root cause of the problem: application.yml first-level key, empty space to write on it. Like Jpa, there are primary keys, and subordinate database is secondary keys.

Solution.

Jpa can move one grid to the left to the direction of the middle arrow.

Considerations for configuration file application.yml

The configuration in the configuration file application.xml requires a space after the corresponding item

This is similar to server: port: 8081spring: mvc: view: prefix: / WEB-INF/jsp/ suffix: .jsp datasource: driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/sunzy username: root password: root another configuration is the properties file configuration

Configuration in the form of KMurv:

# this is the end of the article on "how to solve the problems encountered in the SpringBoot configuration file application.yml" by merId=qy_000000031url= http://localhost:9090/bdt.api/api, the test environment. I hope the above content will be helpful to you so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report