@Bean(name = "dataSource") public HikariDataSource getDataSource(){ Properties props = new Properties(); props.setProperty("jdbcUrl","jdbc:mysql://localhost:3306/springIoc?characterEncoding=utf-8&serverTimezone=GMT%2B8&useSSL=false"); props.setProperty("username","root"); props.setProperty("password","1234"); HikariConfig config = new HikariConfig(props); config.addDataSourceProperty("cachePrepStmts", "true"); HikariDataSource dataSource = new HikariDataSource(config); return dataSource; }
正解👍
赞赞赞,利用函数返回创建第三方bean
Sign in to make a reply
MacanRSG