In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Application-database.properties
# if there is an error when initializing the database, whether to continue to start. Spring.datasource.continue-on-error=false#jdbc driver. Automatic detection through uri by default. Whether the db name spring.datasource.name=test# used by spring.datasource.driver-class-name=com.mysql.jdbc.Driver# randomly generates the db name spring.datasource.generate-unique-name=false#jdbc url. Urispring.datasource.url=# database connection username for database connection spring.datasource.username=# data connection password username for spring.datasource.password=#DML (if the database specifically sets the corresponding username and password) password for spring.datasource.data-username=#DML (if the database specifically sets the corresponding username and password) username for spring.datasource.data-password=#DDL (if the database is specifically set The password of spring.datasource.schema-username=#DDL (if the database specifically sets the corresponding username and password) the fully qualified name of spring.datasource.schema-password=# Connection pool. The default automatically detects the classpathspring.datasource.type=com.zaxxer.hikari.HikariDataSource#sql script character spring.datasource.sql-script-encoding=UTF-8#sql script separator, which defaults to a semicolon. Spring.datasource.separator=;#dbcp2 connection parameter spring.datasource.dbcp2.*#hikari connection parameter spring.datasource.hikari.*#tomcat connection parameter spring.datasource.tomcat.*
Source code-DataSourceProperties
Load the corresponding spring.datasource configuration parameters.
@ ConfigurationProperties (prefix = "spring.datasource") public class DataSourceProperties implements BeanClassLoaderAware, InitializingBean {private ClassLoader classLoader; / * * Name of the datasource. Default to "testdb" when using an embedded database. * / private String name; / * * Whether to generate a random datasource name. * / private boolean generateUniqueName; / * * Fully qualified name of the connection pool implementation to use. By default, it * is auto-detected from the classpath. * / private Class dataSourceClass = DataSourceBuilder .findType (context.getClassLoader ()); return (dataSourceClass = = null? Null: dataSourceClass.getClassLoader ();}} / * * {@ link Condition} to detect when an embedded {@ link DataSource} type can be used. * If a pooled {@ link DataSource} is available, it will always be preferred to an * {@ code EmbeddedDatabase}. * / static class EmbeddedDatabaseCondition extends SpringBootCondition {private final SpringBootCondition pooledCondition = new PooledDataSourceCondition (); @ Override public ConditionOutcome getMatchOutcome (ConditionContext context, AnnotatedTypeMetadata metadata) {ConditionMessage.Builder message = ConditionMessage .forCondition ("EmbeddedDataSource") If (anyMatches (context, metadata, this.pooledCondition)) {return ConditionOutcome .noMatch (message.foundExactly ("supported pooled data source"));} EmbeddedDatabaseType type = EmbeddedDatabaseConnection .get (context.getClassLoader ()) .getType () If (type = = null) {return ConditionOutcome .noMatch (message.didNotFind ("embedded database") .atAll ());} return ConditionOutcome.match (message.found ("embedded database") .items (type));}
test
@ RunWith (SpringRunner.class) @ SpringBootTestpublic class AppContextTest {@ Qualifier ("dataSource") @ Autowired private DataSource dataSource; @ Testpublic void dataSourceTest () throws SQLException {Connection connection = null; try {connection = dataSource.getConnection (); int transactionIsolation= connection.getTransactionIsolation (); String schema= connection.getSchema (); System.out.println ("transactionIsolation=" + transactionIsolation+ "; schema=" + schema) } catch (SQLException e) {e.printStackTrace ();} finally {if (null! = connection) connection.close ();}}
Spring boot defaults to HikariDataSource database connection pooling.
Druid database connection pool: https://blog.51cto.com/881206524/2121687
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.