backend\src\main\resources\
is a configuration file that defines various configuration properties of Spring Boot applications. This file usually contains database connections, server settings, log configurations, security settings, and other application-level configurations.
File path
backend\src\main\resources\
File content
Here is a typical oneExample of file:
server: port: 8080 servlet: context-path: /erp spring: application: name: mechanical-erp-backend datasource: url: jdbc:mysql://localhost:3306/mechanical_erp?useSSL=false&serverTimezone=UTC username: root password: root driver-class-name: jpa: hibernate: ddl-auto: update show-sql: true properties: hibernate: dialect: .MySQL5InnoDBDialect format_sql: true security: user: name: admin password: admin123 logging: level: root: INFO : DEBUG management: endpoints: web: exposure: include: "*" security: oauth2: resourceserver: jwt: issuer-uri: /oauth/token #Other custom configurationscustom: app: feature-flag: new-ui: true timeout: default: 30s
explain
1. Server configuration
server: port: 8080 servlet: context-path: /erp
- port: Specifies the port number for the application to listen on.
- context-path: Specifies the context path of the application.
2. Spring configuration
spring: application: name: mechanical-erp-backend datasource: url: jdbc:mysql://localhost:3306/mechanical_erp?useSSL=false&serverTimezone=UTC username: root password: root driver-class-name: jpa: hibernate: ddl-auto: update show-sql: true properties: hibernate: dialect: .MySQL5InnoDBDialect format_sql: true security: user: name: admin password: admin123
- : Specify the name of the application.
- datasource: Database connection configuration, including URL, username, password, and driver class name.
-
jpa:
-
-auto: Specifies how Hibernate automatically handles database schemas (e.g.
update
,create
,create-drop
)。 - show-sql: Whether to display SQL statements on the console.
- : Specify the Hibernate dialect to use.
- .format_sql: Whether to format SQL statements.
-
-auto: Specifies how Hibernate automatically handles database schemas (e.g.
- : The default user security configuration, including username and password.
3. Logging configuration
logging: level: root: INFO : DEBUG
-
root: Set the root log level to
INFO
。 -
: Set the log level of a specific package to
DEBUG
。
4. Management Configuration
management: endpoints: web: exposure: include: "*"
- : Expose all management endpoints.
5. Security Configuration
security: oauth2: resourceserver: jwt: issuer-uri: /oauth/token
- -uri: Specifies the URI of the JWT issuer.
6. Custom configuration
custom: app: feature-flag: new-ui: true timeout: default: 30s
- -ui: Customize the function flags and enable the new UI.
- : Customize the default timeout.
Example of usage
Here are some common configuration items and their uses:
Database connection configuration
spring: datasource: url: jdbc:mysql://localhost:3306/mechanical_erp?useSSL=false&serverTimezone=UTC username: root password: root driver-class-name:
- url: Database connection URL.
- username: Database username.
- password: Database password.
- driver-class-name: JDBC driver class name.
JPA configuration
spring: jpa: hibernate: ddl-auto: update show-sql: true properties: hibernate: dialect: .MySQL5InnoDBDialect format_sql: true
- ddl-auto: Controls how Hibernate handles database schema.
- show-sql: Whether to display SQL statements on the console.
- dialect: Specify the Hibernate dialect to use.
- format_sql: Whether to format SQL statements.
Log configuration
logging: level: root: INFO : DEBUG
- : Set the root log level.
- : Sets the log level for a specific package.
Manage endpoint configuration
management: endpoints: web: exposure: include: "*"
- include: Expose all management endpoints.
Summarize
-
(Configuration file):
- Purpose: Defines various configuration properties of Spring Boot applications.
- content: Contains server configuration, Spring configuration, log configuration, security configuration, and other application-level configurations.
- effect: Used to configure the behavior and environment of the application to ensure that the application is up and running correctly.
Make sure that the configuration in this file is correct and meets the overall requirements of the project.
This is the article about the configuration files of Spring Boot application in the JAVA system. For more related Spring Boot configuration files, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!