我创建了一个rest Web服务应用程序,该应用程序将通过查询数据库来获取特定属性的值。 我在日志中间歇性地遇到以下错误: java.util.concurrent.ExecutionException:com.bestbuy.fews.exception.DBConnectionException
在大多数情况下,我也会获得所需的输出。
考虑到这可能是一个异步调用问题,我对logback.xml文件进行了更改,但还是没有运气。
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--<include resource="org/springframework/boot/logging/logback/base.xml"/>-->
<property resource="logback-${spring.profiles.active}.xml" />
<!--<property name="LOG_PATH" value="${LogFilePath}" />-->
<appender name="ROLLING_FILE_TIMEBASED_POLICY" class="ch.qos.logback.core.FileAppender">
<file>${LogFilePath}/bestbuy_zrrbzr.log</file>
<encoder>
<pattern>%d:%-7p:%t: %-60m [%X{PrimaryKey}]: %-25c{1}%n
</pattern>
</encoder>
</appender>
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender" neverBlock="true">
<appender-ref ref="ROLLING_FILE_TIMEBASED_POLICY" />
</appender>
<root level="INFO">
<appender-ref ref="ASYNC" />
</root>
</configuration>
build.gradle
group 'com.bestbuy.fews'
version '1.0-SNAPSHOT'
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
sourceCompatibility = 1.8
repositories {
mavenLocal()
maven { url "http://repo.maven.apache.org/maven2" }
jcenter { url "https://jcenter.bintray.com" }
maven { url "https://repo.spring.io/milestone" }
flatDir {
dirs '../GetRevisionNo/src/lib'
}
}
buildscript {
ext {
springBootVersion = '1.5.3.RELEASE'
}
repositories {
maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.springBootVersion}")
}
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.10'
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-starter-security'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
compile 'org.springframework:spring-context'
compile 'org.springframework:spring-context-support'
compile('org.springframework.boot:spring-boot-starter-data-jpa'){
exclude group:'org.apache.tomcat', module:'tomcat-jdbc'
}
//compile name: 'javax.resource'
//compile name: 'logback-classic-1.1.9'
//compile name: 'logback-core-1.1.9'
compile('commons-dbcp:commons-dbcp:1.3')
testCompile group: 'junit', name: 'junit', version: '4.11'
compile fileTree(dir:'src/lib', include:['**/**.*jar'])
//compile files ('lib/ojdbc14.jar')
//compile name: 'javax.resource'
}
configurations {
compile.exclude group:'ch.qos.logback'
}
DAO层代码
@Repository
interface EomsOrderEventRevisionRepository extends CrudRepository<EomsOrderEventRevision, String> {
List<EomsOrderEventRevision> findAll()
@Query("FROM EomsOrderEventRevision WHERE orderNo=:orderNo")
EomsOrderEventRevision findByOrderNo(@Param("orderNo") String orderNo)
}
在日志中,我可以看到上述异常的计数接近 如果我点击Web服务,则说20次50次。
谢谢您的帮助。