我无法重现错误,但让我更正您的属性文件,以便 Spring 实际上可以读取您的属性,如果您使用的是 SpringBoot 1.4 及更高版本。
正如我在post with the same error 中发现的那样,为了解决您正在尝试增加datasource.max-active 和其他属性的问题,对吧?
所以如果属性不在this default application properties中,那么你必须把它们写成
spring.jpa.properties.*= # Additional native properties to set on the JPA provider.
据此,我建议您将application.properties 文件更改为以下内容:
spring.datasource.url = jdbc:derby:/spring-boot/db;create=true
spring.datasource.username = admin
spring.datasource.password = 1234
# this one is incorrect
# spring.datasource.driver = org.apache.derby.jdbc.EmbeddedDriver
# replace with the one below, otherwise Spring will use his own
# derby driver
spring.datasource.driver-class-name = org.apache.derby.jdbc.EmbeddedDriver
# this one is incorrect as well
# hibernate.dialect = org.hibernate.dialect.DerbyDialect
# use the following way
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.DerbyDialect
spring.jpa.generate-ddl = true
spring.jpa.hibernate.ddl-auto = update
spring.jpa.properties.hibernate.current_session_context_class = org.springframework.orm.hibernate4.SpringSessionContext
# and in order for these guys to work you have to know
# spring.datasource.max-active=100
# spring.datasource.max-idle=8
# spring.datasource.min-idle=8
# your dbcp and look for documentation
# below is the example for Tomcat
spring.datasource.tomcat.max-active=100
spring.datasource.tomcat.max-idle=8
spring.datasource.tomcat.min-idle=8
# make sure you check out the logging
# this is IMPORTANT to see that your
# properties were ACTUALLY picked up
logging.level.org.springframework.web = DEBUG
logging.level.org.hibernate = DEBUG
可以帮助您克服困难的前 3 个属性是最难解决的。我从this post here, last answer 中挑选了一个知识。它还链接到Spring Boot 1.4.1.RELEASE documentation。
最后但并非最不重要的一点是,您必须确保您的 max-idle 属性实际上已被 Spring 拾取。这就是为什么我添加了两个
最后的日志记录和调试属性。
如果您仔细查看日志文件,请检查它们设置的值。这是这条线对我的看法
2016-11-17 11:40:27.875 DEBUG 32079 --- [ main] o.hibernate.internal.SessionFactoryImpl : Instantiating session factory with properties: {java.vendor=Oracle Corporation, sun.java.launcher=SUN_STANDARD, catalina.base=/tmp/tomcat.736868414125414090.8080, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, catalina.useNaming=false, hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy, os.name=Linux, sun.boot.class.path=/usr/users/nikiforo/src/jdk1.8.0_73/jre/lib/resources.jar:/usr/users/nikiforo/src/jdk1.8.0_73/jre/lib/rt.jar:/usr/users/nikiforo/src/jdk1.8.0_73/jre/lib/sunrsasign.jar:/usr/users/nikiforo/src/jdk1.8.0_73/jre/lib/jsse.jar:/usr/users/nikiforo/src/jdk1.8.0_73/jre/lib/jce.jar:/usr/users/nikiforo/src/jdk1.8.0_73/jre/lib/charsets.jar:/usr/users/nikiforo/src/jdk1.8.0_73/jre/lib/jfr.jar:/usr/users/nikiforo/src/jdk1.8.0_73/jre/classes, hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext, java.vm.specification.vendor=Oracle Corporation, java.runtime.version=1.8.0_73-b02, user.name=nikiforo, javax.persistence.validation.mode=AUTO, user.language=en, sun.boot.library.path=/usr/users/nikiforo/src/jdk1.8.0_73/jre/lib/amd64, PID=32079, java.version=1.8.0_73, user.timezone=Europe/Berlin, sun.arch.data.model=64, java.endorsed.dirs=/usr/users/nikiforo/src/jdk1.8.0_73/jre/lib/endorsed, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, file.encoding.pkg=sun.io, file.separator=/, java.specification.name=Java Platform API Specification, java.class.version=52.0, user.country=US, java.home=/usr/users/nikiforo/src/jdk1.8.0_73/jre, java.vm.info=mixed mode, os.version=4.1.20-11-default, hibernate.boot.CfgXmlAccessService.key=org.hibernate.boot.cfgxml.spi.LoadedConfig@6abb7b7d, hibernate.connection.datasource=org.apache.tomcat.jdbc.pool.DataSource@5c7dfc05{ConnectionPool[defaultAutoCommit=null; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=org.apache.derby.jdbc.EmbeddedDriver; maxActive=100
这是一条很长的线路,但正如你所见,max-active 已设置。
如果您想查看我在哪个简单的 Spring-Data-REST 应用程序中尝试了 derby 和以下属性,请查看 this mine GitHub project: derby-tomcat-database-error branch
可能有帮助,可能没有,如果我错了,请告诉我,我会删除帖子。