The reason is that there is also a username property in the system. At this time, the system variable overwrites the value in Properties. At this time, the username value is obtained as the system user name Administrator, and the password is the password in properties to query the database. At this time, the user name and password If it does not match, an error will be reported. When Spring completes the injection, it uses the “${..}” method to get the value to complete the injection. And through this expression, the JVM system properties can also be directly obtained……….
Solution 1: Replace the username in the properties file with user or other strings to successfully obtain a connection to access the database. Suggestion: When username is a sensitive word, try not to use username for the sake of safety.
Solution 2: Modify the Spring configuration file to: <context:property-placeholder location=”classpath:/jdbc.properties” system-properties-mode=”FALLBACK / NEVER”/>
Add a system-properties-mode property
This attribute has three values:
FALLBACK — default value, overwrite if it does not exist
NEVER — do not cover
OVERRIDE — cover
Similar Posts:
- [Solved] Spring Error: java.sql.SQLException: Access denied for user ‘${user}’@’localhost’ (using password: YES)
- Spring Boot UrlResource loading classpath error: unknown protocol: classpath
- [Solved] Mybatis-config Error: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: failed to parse the connection string near ‘;useUnicode=true&
- [transfer] could not resolve placeholder solution
- [Solved] Failed to bind properties under ” to com.zaxxer.hikari.Hikari DataSource Spring Boot
- Springboot Error: Failed to configure a DataSource: ‘url’ attribute is not specified and no embedd
- Activemq Console Error: java.lang.SecurityException: User name [system] or password is invalid.
- [Solved] Spring introduces the properties variable Error: org.springframework.beans.TypeMismatchException…
- Laravel [1045] Solution Access denied for user’homestead’@’localhost’
- [Warning] Using a password on the command line interface can be insecure. (Solved)