spring引导数据sql映像文件

u2nhd7ah  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(370)

我的项目中有一个data.sql,我想用insert命令添加一个配置文件图片。

我总是犯这个错误。

  1. 2021-03-03 16:26:52.368 INFO 20476 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
  2. Exception in thread "task-2" org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #3 of class path resource [data.sql]: insert into profile (profile_id,picture, start_in_company,attendance,tel_nr,location,introduction,degree,job_position,hobby,university) values (1234, lo_import('Testimage.PNG') ,'2020-02-07', '2020-02-11', '015773845515', 'Stuttgart', 'hello, my name is artur', 'Software Engineering', 'Developer', 'Tennis, Fussball','Uni Ulm'); nested exception is org.postgresql.util.PSQLException: ERROR: could not open server file "Testimage.PNG": No such file or directory
  3. at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:622)
  4. at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254)
  5. at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:49)
  6. at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:202)
  7. at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.initSchema(DataSourceInitializer.java:119)
  8. at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:91)
  9. at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:38)
  10. at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
  11. at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
  12. at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
  13. at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
  14. at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
  15. at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:99)
  16. at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.access$100(DataSourceInitializedPublisher.java:50)
  17. at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher$DataSourceSchemaCreatedPublisher.lambda$postProcessEntityManagerFactory$0(DataSourceInitializedPublisher.java:200)
  18. at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
  19. at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
  20. at java.base/java.lang.Thread.run(Thread.java:834)
  21. Caused by: org.postgresql.util.PSQLException: ERROR: could not open server file "Testimage.PNG": No such file or directory
  22. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
  23. at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
  24. at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:323)
  25. at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:473)
  26. at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:393)
  27. at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:322)
  28. at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:308)
  29. at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:284)
  30. at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:279)
  31. at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
  32. at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
  33. at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:601)
  34. ... 17 more

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题