我有一个Media实体,它有一些用户上传文件的基本字段.为了保存上传文件的字节,我想创建一个包含该功能的自定义存储库.按照Spring文档中的步骤,我创建了一个如下所示的界面:
public interface MediaBytesRepository
{
public byte[] getBytes(Media media) throws IOException;
public void saveBytes(Media media, byte[] bytes) throws IOException;
public void appendBytes(Media media, byte[] bytes) throws IOException;
public void deleteBytes(Media media) throws IOException;
public boolean bytesExist(Media media) throws IOException;
}
Run Code Online (Sandbox Code Playgroud)
然后我提供了一个名为的接口的实现 MediaBytesRepositoryImpl
有了这个,我创建了以下界面:
public interface MediaRepository extends JpaRepository<Media, Long>, MediaBytesRepository
{
}
Run Code Online (Sandbox Code Playgroud)
现在,当我启动服务器时,我得到以下堆栈跟踪:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mediaRepository': FactoryBean threw exception on object creation; …Run Code Online (Sandbox Code Playgroud)