Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-01 11:53:43 10月04日 Update

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.

Tags: Configuration files questions spaces colons articles between code methods more root project one grid good practical the following figure item content that is form Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Information vpn Shulou Technology Shulou Tech Info