Я получаю следующее сообщение об ошибке при попытке запустить весной веб-приложения:java.io.FileNotFoundException: путь к классам ресурсов [timex-servlet.properties] не может быть открыт, потому что не существует
2012-04-12 13:53:20,491 ERROR [org.springframework.web.servlet.DispatcherServlet] -
Context initialization failed
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [timex-servlet.properties] cannot be opened because it does not exist
java.io.FileNotFoundException: class path resource [timex-servlet.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:137)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:172)
Я запускаю Tomcat (версия 6.x) через затмение. Я попытался положить timex-servlet.properties в следующих каталогах, но безрезультатно:
WebContent\WEB-INF
WebContent\WEB-INF\classes
WebContent\
Вот ссылка на timex-servlet.properties в Timex-servlet.xml:
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"
value="timex-servlet.properties" />
</bean>
Есть несколько потоков SO, имеющих дело с тем же сообщением, которое говорит, чтобы положить classpath: перед ссылкой файла свойств. Так что я попытался следующие, которые также не работают:
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"
value="classpath:timex-servlet.properties" />
</bean>
'WEB-INF \ classes' - это правильное местоположение в файле WAR. 'classpath: file.properties' - это правильный способ указать, что файл будет расположен здесь. Я могу только предположить, что Eclipse может строить вашу WAR иначе, чем вы ожидаете. Работает ли он с автономным Tomcat? –