java.lang.IllegalArgumentException: Property 'dataSource' is required
at org.springframework.jdbc.support.JdbcAccessor.afterPropertiesSet
This is the mistake I made when doing the login interface, as shown below:
At that time, I read a lot of information on the Internet, and they all said that in the code below, "druid.properties" had more "/". But I did not make this mistake.
Wrong wording: getResourceAsStream(" / druid.properties");
Correct writing:
InputStream is = JDBCUtils.class.getClassLoader().getResourceAsStream("druid.properties");
Later, through a translation error, I understood the original meaning of java.lang.IllegalArgumentException: Property'dataSource' is required, and the dataSource is still null.
Finally, after repeated inspections, an error was found: the data source has been declared in the member variable. Here should be assigned directly, otherwise the data source is still null.
// 3.初始化连接池对象
DataSource ds = DruidDataSourceFactory.createDataSource(pro);
Correct writing:
ds = DruidDataSourceFactory.createDataSource(pro);