我的spring应用程序启动,尝试创建H2数据库,然后由于以下两个错误而崩溃。我该如何解决?
第一个错误:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 15 in XML document from
class path resource [org/springframework/jdbc/support/sql-error-codes.xml] is invalid; nested exception
is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
此文件的第15行如下。可以手动包含spring-beans-2.0.dtd吗?这是有效的链接,但可能是防火墙阻止了它。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!--
...
-->
<beans>
第二个错误:
Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL
grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? order by
JOB_INSTANCE_ID desc]; nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table
"BATCH_JOB_INSTANCE" not found; SQL statement:
SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? order by
JOB_INSTANCE_ID desc [42102-199]
我尝试将spring.batch.initialize-schema=always
之类的弹簧设置切换为无效。
答案 0 :(得分:0)
问题是文件编码。使用.flat()
运行jar可以解决该问题。这是特定于环境的,可能与每个人都不相关。