Home > Back-end >  Help!!!!!! More about springboot2.0 yml data source configuration error
Help!!!!!! More about springboot2.0 yml data source configuration error

Time:01-14

As my first yml configuration
Server:
Port: 8080
The servlet:
The context path:/eslsystem

Netty:
Port: 8899


Spring:
Datasource:
Druid:
Primary:
Username: root
Password: 123456
The driver - class - name: com. Mysql. Cj). The JDBC driver
JDBC - url: JDBC: mysql://localhost: 3306/eslsystem_info? useUnicode=true& CharacterEncoding=utf-8 & amp; ZeroDateTimeBehavior=convertToNull& AllowMultiQueries=true& ServerTimezone=UTC
Shrio:
JDBC - url: JDBC: mysql://localhost: 3306/eslsystem_shrio? useUnicode=true& CharacterEncoding=utf-8 & amp; ZeroDateTimeBehavior=convertToNull& AllowMultiQueries=true& ServerTimezone=UTC
Username: root
Password: 123456
The driver - class - name: com. Mysql. Cj). The JDBC driver

InitialSize: 5
MinIdle: 5

MaxActive: 20
MaxWait: 60000
TimeBetweenEvictionRunsMillis: 60000
MinEvictableIdleTimeMillis: 300000
ValidationQuery: SELECT 1 FROM DUAL
TestWhileIdle: true
TestOnBorrow: false
TestOnReturn: false
PoolPreparedStatements: true

Filters: stat, wall, log4j
MaxPoolPreparedStatementPerConnectionSize: 20
UseGlobalDataSourceStat: true
ConnectionProperties: druid. Stat. MergeSql=true; Druid. Stat. SlowSqlMillis=500
HTTP:
Multipart:
Max - file - size: 10 MB
Max - request - size: 10 MB

Redis:
Shrio:
Host: 127.0.0.1
Port: 6379
Timeout: 0
Password:

Mybatis:
The config - location: the classpath: XML mybatis - config.
The main data source configuration classes:
 @ Configuration 
@ MapperScan (basePackages="com. GKTS. Eslsystem. Primary. Mapper", sqlSessionFactoryRef="primarySqlSessionFactory")
Public class MybatisDataSourcePrimaryConfig {

@ Bean (name="primaryDataSource")
@ ConfigurationProperties (prefix="spring. The datasource. The druid. Primary")
@ Primary
Public DataSource primaryDataSource () {
Return DataSourceBuilder. The create (). The build ();

}

@ Primary
@ Bean (" primarySqlSessionFactory ")
Public SqlSessionFactory primarySqlSessionFactory (@ the Qualifier (" primaryDataSource ") the DataSource DataSource) throws the Exception {
SqlSessionFactoryBean sqlSessionFactory=new SqlSessionFactoryBean ();
SqlSessionFactory. SetDataSource (dataSource);
SqlSessionFactory. SetMapperLocations (new PathMatchingResourcePatternResolver ().
GetResources (" classpath * : mybatis mapper/*. XML "));
Return sqlSessionFactory. GetObject ();
}

@ Primary
@ Bean (" primaryTransactionManager ")
Public DataSourceTransactionManager primaryTransactionManager (@ the Qualifier (" primaryDataSource ") the DataSource DataSource) {
Return new DataSourceTransactionManager (dataSource);
}

@ Primary
@ Bean (name="primarySqlSessionTemplate")
Public SqlSessionTemplate primarySqlSessionTemplate (@ the Qualifier (" primarySqlSessionFactory ") SqlSessionFactory SqlSessionFactory) {
Return new SqlSessionTemplate (sqlSessionFactory);
}

}

Shiro data source configuration classes:
 @ Configuration 
@ MapperScan (basePackages="com. GKTS. Eslsystem. Shiro. ShiroMapper", sqlSessionFactoryRef="shiroSqlSessionFactory")
Public class MybatisDataSourceShiroConfig {

@ Bean (name="shiroDataSource")
@ ConfigurationProperties (prefix="spring. The datasource. The druid. Shiro")
Public DataSource shrioDataSource () {
Return DataSourceBuilder. The create (). The build ();
}

@ Bean (" shiroSqlSessionFactory ")
Public SqlSessionFactory shrioSqlSessionFactory (@ the Qualifier (" shiroDataSource ") the DataSource DataSource) throws the Exception {
SqlSessionFactoryBean sqlSessionFactory=new SqlSessionFactoryBean ();
SqlSessionFactory. SetDataSource (dataSource);
SqlSessionFactory. SetMapperLocations (new PathMatchingResourcePatternResolver ().
GetResources (" classpath * : mybatis shiroMapper/*. XML "));
Return sqlSessionFactory. GetObject ();
}

@ Bean (" shiroTransactionManager ")
Public DataSourceTransactionManager shrioTransactionManager (@ the Qualifier (" shiroDataSource ") the DataSource DataSource) {
Return new DataSourceTransactionManager (dataSource);
}

@ Bean (name="shiroSqlSessionTemplate")
Public SqlSessionTemplate shrioSqlSessionTemplate (@ the Qualifier (" shiroSqlSessionFactory ") SqlSessionFactory SqlSessionFactory) {
Return new SqlSessionTemplate (sqlSessionFactory);
}
}

Then execute SQL statements times wrong:
 org. Mybatis. Spring. MyBatisSystemException: nested exception is org. Apache. Ibatis. Exceptions. PersistenceException: 
# # # Error querying the database. Cause: Java. Lang. IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.
# # # The error may exist in The file [F: \ ESL \ eslsystem \ target \ classes \ mybatis \ shiroMapper \ UserMapper XML]
# # # The error may involve com. GKTS. Eslsystem. Shiro. ShiroMapper. UserMapper. GetOneUserInfo
# # # The error occurred while executing a query
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related