我仍然无法理解这件事:
这就是我的项目的样子:
--app
--app-core (spring)
--app-model (pojo)
--app-service (jersey) >> final package as war (dependencies (appcore+appmodel))
现在我的 applicationContext.xml 应该放在哪里???Spring 的依赖项仅适用于 app-core ???? ...
更新
app-core (spring) 有 applicationContext.xml,知道我想将 JNDI 与嵌入式 tomcat (tomcat-maven-plugin) 一起使用。
在 webapp/META-INF 中创建了context.xml
它看起来像:-
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="nweb" path="/nweb" reloadable="true">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource name="jdbc/TestDS" auth="Container"
type="javax.sql.DataSource"
driverClass="net.sourceforge.jtds.jdbc.Driver"
url="jdbc:sqlserver://localhost:1433;DatabaseName=TestData"
username="sa" password=""/>
</Context>
..
我的 applicationContext.xml : -
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/TestDS"></property>
</bean>
</beans>
有了上面我得到以下错误:
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: javax.naming.NameNotFoundException: Name TestDSis not bound in this
Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
at
如果我错过了什么,有什么建议吗?