2016-02-05 77 views
1

當我在Tomcat的運行.war文件,日誌顯示春天,Tomcat的,爪哇

錯誤[com.configleon.configurer.WebPropertyConfigurer] - 未在JVM設置中指定的 'configLocation' 變量!

錯誤[org.springframework.web.context.ContextLoader] - 上下文初始化失敗

這我的代碼:

<!-- configlion property configurator --> 
<bean class="com.configleon.configurer.WebPropertyConfigurer"> 
    <property name="propertyResources"> 
     <bean class="com.configleon.resource.WebPropertyResources"/> 
    </property> 
</bean> 

任何人都可以幫我嗎?

+0

試試這個,我相信JVM屬性設置不正確 - https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features- external-config.html#boot-features-external-config-application-property-files –

回答

1

的第一個錯誤[com.configleon.configurer.WebPropertyConfigurer]

看到here

和第二個

ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed 

在部署環境中,只要確保你的服務器類路徑中有包括Spring jar庫(例如spring-2.5.6.jar)。

對於Spring3,ContextLoaderListener被移動到spring-web.jar中,您可以從Maven中央存儲庫獲取庫。

標記

<dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>3.0.5.RELEASE</version> 
    </dependency> 
+0

我可以在哪裏放置代碼來定義JVM變量?我曾嘗試在我的config.properties中添加'-DconfigLocation = test',但仍然得到相同的錯誤 –

+0

您可以將jvm變量放在tomcat web容器的CATALINA_OPT或JAVA_OPT中。 –

+0

謝謝Girish,這是工作.. –