我正在编写一个Spring批处理应用程序,我将Oracle用作数据存储。当运行构建和spring加载时,它正在寻找hsqldb,尽管我已将ORACLE定义为databaseType。以下是日志中的错误:
无法加载JDBC驱动程序类org.hsqldb.jdbcDriver
我不想使用单独的数据库来存储spring批量元数据。 请告知为什么春季批量寻找hsqldb。
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager"/>
<property name="dataSource" ref="paymentDataSource"/>
<property name="databaseType" value="ORACLE" />
</bean>
<bean id="paymentDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url" value="jdbc:oracle:thin:@boxxxx:1521:xxxxx">
</property>
<property name="username" value="xxx"></property>
<property name="password" value="xxx"></property>
</bean>
<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" xmlns="http://www.springframework.org/schema/beans" />
[java] org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath*:beanRefContext.xml], factory key [applicationContext-main]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseContext' defined in URL : Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.context.support.GenericXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRepository': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.hsqldb.jdbcDriver'
[java] at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:388)
[java] at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:563)
[java] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
[java] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
答案 0 :(得分:0)
您是否已在application.properties
中定义了相应的属性?
例如:
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
Oracle JAR在pom.xml
中的依赖性?