[英]How to find "spring.datasource.url=" for application.properties?
我是开发的初学者。
如何获取 application.properties 的“spring.datasource.url=”?
应用程序.properties
spring.datasource.url=jdbc:mysql://localhost:3306/sms?useSSL=fals&serverTimezone=UTC&useLegacyDatetimecode=false
spring.datasource.username=root
spring.datasource.password=123123
#Hibernate
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
#Hibernate auto ddl
spring.jpa.hibernate.ddl-auto=update
logging.level.org.hibernate.SQL=DEBUG
我的数据库在此处输入图像描述
注入dataSourceProperties
,并使用determineUrl
:
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
...
@Autowired
DataSourceProperties dataSourceProperties;
然后你可以打电话:
String dbUrl = dataSourceProperties.determineUrl();
你可以使用属性:
包 java.util.Properties
Properties springProperties = new Properties();
springProperties.getProperty("spring.datasource.url");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.