Ошибка при загрузке файла свойств

Я получаю ошибку при загрузке файла свойств. Я получаю следующую ошибку: java.io.FileNotFoundException: neosEntitelment.properties (система не может

find the file specified)
        at java.io.FileInputStream.open0(FileInputStream.java)
        at java.io.FileInputStream.open(FileInputStream.java:195)
        at java.io.FileInputStream.<init>(FileInputStream.java:138)
        at java.io.FileInputStream.<init>(FileInputStream.java:93)
        at noes.Entitelment.CreateProperties.<init>(CreateProperties.java:45)
        at noes.Entitelment.NeosDatabase.oracleJdbcConnection(NeosDatabase.java:68)
        at noes.Entitelment.NeosDatabase.getDataByDB(NeosDatabase.java:20)
        at noes.Entitelment.SoapWebService.getEntitelmentDetails(SoapWebService.java:254)
        at noes.Entitelment.Entitelment.doGet(Entitelment.java:27)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
        at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:110)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

Структура проекта:

Project
    -src
    -neosEntitelment.properties

Вот мой код

Properties prop = new Properties();
prop.load(new FileInputStream("neosEntitelment.properties"));
setNeoJdbcConnectionUrl(prop.getProperty("neo.jdbc.connection.url"));
setNeoUserName(prop.getProperty("neo.db.userName"));
setNeoPassword(prop.getProperty("neo.db.password"));

2 ответа

Решение

Я предлагаю U использовать "getClass.getResourceAsStream('/neosEntitelment.properties')"

Поместите файл "neosEntitelment.properties" в каталог "src".

Другие вопросы по тегам