我正在创建一个Spring启动应用程序,我正在初始化spring文件中的数据源。但是,得到如下错误:数据源无法通过Spring启动应用程序进行初始化?
java.lang.NullPointerException: null
at com.howtodoinjava.demo.controller.JdbcCustomerDAO.insert(JdbcCustomerDAO.java:28) ~[classes/:na]
at com.howtodoinjava.demo.controller.EmployeeController.getCustomer(EmployeeController.java:36) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91]
at org
获得NullPointerException异常下面一行:
conn = dataSource.getConnection();
我的源代码是有在GitHub https://github.com/thesnehajain/spring_boot/tree/master/springbootdemo
这是因为'dataSource'是没有得到注射;尝试使用'@ Autowired'注释构造函数注入,稍后调整它以使用setter注入 –
Stil注释后给出相同的错误。 – Vicky