我北工大学生一枚, 初学maven 在配制过程中遇到了问题, 烦请大神帮助…
问题描述:
pom.xml 中这样定义:
……
<!-- 指定各自的profile -->
<profile>
<id>chen</id>
<properties>
<database.url>jdbc:mysql:127.0.0.1:3306/tick_mysql</database.url>
<database.user>root</database.user>
<database.password>root</database.password>
</properties>
</profile>
……
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
……
Spring中这样定义(tick-persist中 resource中application-datasource.xml )
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!--########## jdbc连接信息 ########## -->
<property name="driverClass">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="jdbcUrl">
<value>${database.url}</value>
</property>
<property name="user">
<value>${database.user}</value>
</property>
<property name="password">
<value>${database.password}</value>
</property>
…………
在tick-service测试程序
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:application-service-config.xml")
public class TestService {
@Autowired
private IUserService userService;
@Test
public void register() {
User user = new User();
user.setUsername("ttttttt");
userService.register(user);
System.out.println(user.getId());
}
}
当 application-datasource.xml中直接写 数据库链接, 名字,密码的值时Junit可通过;
当写成上面时就报驱动不配
ERROR: HHH000319: Could not get database metadata
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:278)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:119)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:143)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:132)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.initializeAutomaticTestTable(C3P0PooledConnectionPoolManager.java:772)
烦请知道的大神帮忙解答 , 谢谢
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.createPooledConnectionPool(C3P0PooledConnectionPoolManager.java:696)
ERROR: HHH000319: Could not get database metadata
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:278)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:119)
主Pom.xml 在tick-master中
测试类: ServiceTest 在 tick-service 的src/test/java中
datasource的配制在 tick-persist的src/main/resources中
源码地址: git@github.com:cc001116/tick-master.git
百度云:http://pan.baidu.com/s/1i389WOH
请大神助~~~
已解决 Spring 配制文件schema 出现问题 还有就是缓存原因