我需要升级我的应用程序中的Gradle和一些软件包,但是在那之后,Spring Boot或jOOQ似乎并没有加载它的配置或类似的东西。
Build.gradle重要部分:
...
plugins {
id 'java'
id 'idea'
id 'nu.studer.jooq' version '3.0.3'
id 'org.springframework.boot' version '2.2.1.RELEASE'
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: '2.2.1.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jooq', version: '2.2.1.RELEASE'
compile group: 'com.zaxxer', name: 'HikariCP', version: '3.4.1'
compile group: 'org.firebirdsql.jdbc', name: 'jaybird-jdk18', version: '2.2.12'
compile group: 'org.jooq', name: 'jooq', version: '3.12.3'
compile group: 'org.jooq', name: 'jooq-codegen', version: '3.12.3'
jooqRuntime 'org.firebirdsql.jdbc:jaybird-jdk18:2.2.12'
}
ext['jooq.version'] = '3.12.3'
...
这是我要执行的代码:
List<LinhaRelatoFichaProduto> notas =
dsl.selectFrom(notasEntrada.unionAll(notasSaida).asTable())
.orderBy(field(name("data")),
field(name("tipo")),
field(name("numero")),
field(name("datahora"))
).fetch().into(LinhaRelatoFichaProduto.class);
但是我在这行得到一个NullPointerException:
@Override
public final <R extends Record, E> RecordMapper<R, E> provide(final RecordType<R> rowType, final Class<? extends E> type) {
if (TRUE.equals(configuration.settings().isCacheRecordMappers())) << HERE! configuration is null for some reason
return Cache.run(configuration, new CachedOperation<RecordMapper<R, E>>() {
@Override
public RecordMapper<R, E> call() {
return new DefaultRecordMapper<R, E>(rowType, type, configuration);
}
}, DATA_CACHE_RECORD_MAPPERS, Cache.key(rowType, type));
else
return new DefaultRecordMapper<R, E>(rowType, type, configuration);
}
这是完整的错误堆栈:
java.lang.NullPointerException
at org.jooq.impl.DefaultRecordMapperProvider.provide(DefaultRecordMapperProvider.java:83)
at org.jooq.impl.ResultImpl.into(ResultImpl.java:1369)
at br.com.tropicalia.service.RelatoFichaProdutoService.start(RelatoFichaProdutoService.java:90)
at br.com.tropicalia.service.RelatoFichaProdutoService$$FastClassBySpringCGLIB$$ac9b0452.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at br.com.tropicalia.service.RelatoFichaProdutoService$$EnhancerBySpringCGLIB$$dd439b32.start(<generated>)
at br.com.tropicalia.ui.MainController.gerarRelatorio(MainController.java:127)
at br.com.tropicalia.ui.MainController.lambda$initialize$2(MainController.java:79)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8411)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:432)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:410)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$3(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
@Override
public final <R extends Record, E> RecordMapper<R, E> provide(final RecordType<R> rowType, final Class<? extends E> type) {
if (TRUE.equals(configuration.settings().isCacheRecordMappers())) << HERE! configuration is null for some reason
return Cache.run(configuration, new CachedOperation<RecordMapper<R, E>>() {
@Override
public RecordMapper<R, E> call() {
return new DefaultRecordMapper<R, E>(rowType, type, configuration);
}
}, DATA_CACHE_RECORD_MAPPERS, Cache.key(rowType, type));
else
return new DefaultRecordMapper<R, E>(rowType, type, configuration);
}
我的自定义DSL上下文:
@Configuration
public class FirebirdJooqConfiguration {
@Bean(name = "firebirdDSLContext")
public DSLContext firebirdDSLContext(@Qualifier("firebirdDataSource") DataSource dataSource) {
return DSL.using(new DefaultConfiguration()
.set(dataSource)
.set(SQLDialect.FIREBIRD)
.set(new DefaultExecuteListenerProvider(new JooqExceptionTransformer()))
.set(new DefaultRecordMapperProvider()));
}
}
那么...如何避免jOOQ配置为空?
答案 0 :(得分:2)
那是jOOQ中的一个错误:https://github.com/jOOQ/jOOQ/issues/9621
从DefaultRecordMapperProvider
中删除Configuration
,它应该可以工作:
@Bean(name = "firebirdDSLContext")
public DSLContext firebirdDSLContext(@Qualifier("firebirdDataSource") DataSource dataSource) {
return DSL.using(new DefaultConfiguration()
.set(dataSource)
.set(SQLDialect.FIREBIRD)
.set(new DefaultExecuteListenerProvider(new JooqExceptionTransformer()))
/* .set(new DefaultRecordMapperProvider()) */ );
}