我正在将 NestJS 与 TypeORM 结合使用,并尝试保存用户与消息的对话。我将对话实体上的消息字段设置为cascade: true。但是当我尝试这段代码时:
const user3: User = { login: 'admin', createdBy: 'system', lastModifiedBy: 'system' };
const user4: User = { login: 'user', createdBy: 'system', lastModifiedBy: 'system' };
const message1: Message = { content: 'Hello How are you? ', createdBy: user3.login, lastModifiedBy: user3.login };
const conversation1: Conversation = { sender: user3, reciever: user4, messages: [message1] };
getConnection().getRepository(Conversation).save(conversation1);
Run Code Online (Sandbox Code Playgroud)
它创建这个查询:
INSERT INTO "message"("id", "createdBy", "createdDate", "lastModifiedBy", "lastModifiedDate", "content", "conversationSenderId", "conversationRecieverId", "conversationDate") VALUES (?, ?, datetime('now'), ?, datetime('now'), ?, …Run Code Online (Sandbox Code Playgroud) 我有一个简单的Spring Batch应用程序,它从数据库中提取记录,只是将行打印到屏幕上.只是一个简单的POC应用程序.
该应用程序适用于Spring Boot 1.2.1.RELEASE,但当我更新到1.2.3.RELEASE时,我收到一条错误消息"没有定义类型为[javax.sql.DataSource]的限定bean"
我不确定这是Spring Boot问题还是Spring Batch问题.
有没有办法为Spring Batch存储库显式定义数据源?
完整堆栈跟踪.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Collection org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration.dataSources; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [demo/BatchConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceInitializer': Invocation of init method failed; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] is …Run Code Online (Sandbox Code Playgroud)