我是scala和vaadin的新手,我只是在試驗。我試圖在我的scala vaadin應用程序中使用spring應用程序上下文和spring di,但無法獲取要注入的數據源。我不知道,也許我做一些根本性的錯誤,但這裏是我的代碼:我想在我的Scala vaadin應用程序中使用spring應用程序上下文和spring di,但無法獲得要注入的數據源
的web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<description>
Vaadin production mode</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
<servlet>
<servlet-name>Scalatest Application</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
<init-param>
<description>Vaadin application class to start</description>
<param-name>application</param-name>
<param-value>com.example.scalatest.ScalaApp</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Scalatest Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
應用程序上下文:
<bean id="main" class="com.example.scalatest.ScalaApp">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="url"/>
<property name="username" value="root"/>
<property name="password" value="pass"/>
</bean>
,並在我的斯卡拉類
var dataSource:DataSource = _;
def setDataSource(datasource:DataSource){
dataSource = datasource;
}
不工作,ds在啓動時爲空。 任何人都可以引導我嗎?