解决方案:
1:使用绝对路径
properties.load(new FileInputStream("D:\\druid.properties"));
dataSource = DruidDataSourceFactory.createDataSource(properties);
2:使用类加载器
InputStream is=DruidConnection.class.getClassLoader().getResourceAsStream("druid.properties");
properties.load(is);
dataSource = DruidDataSourceFactory.createDataSource(properties);