简体   繁体   中英

Unable to access classpath file in application.properties file

Am developing application in springboot using Msaccess database. My database file placed inside src/main/resources . I have configured database details in application.properties file. When I tried to load database file in application.properties its not working. Below is what I have tried in application.properties file.

spring.datasource.url=jdbc:ucanaccess://classpath:database.accdb

When I run the application, it return error message:

UCAExc:::4.0.4 given file does not exist: classpath:database.accdb

The driver cannot understand that classpath: is a special prefix. It expects a filename (real file path in a filesystem) and classpath:database.accdb is not a real one. Consider constructing the URL dynamically in Java code using ResourceUtils.getFile (this method will return real file name for a classpath resource). Note that it will throw a FileNotFoundException if the resource cannot be resolved to a file in the file system as it may be the case (eg when the resource is inside a JAR file).

Below post is going to help you

Accessing a Microsoft Access database that is saved in the classpath

As i commented earlier, it should be an absolute path or path to the source directoy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM