这是“随着 JAVA 错误转向”的下一部分。
所以我有这个应用程序,它编译得很好。我在这里阅读了一个线程并将我的 app-context.xml 和 application-context.xml 移动到主目录下的 SOURCES 文件夹中,而不是在 Web-Inf/ 目录内。
我收到此错误:
[ Thread-22] ContextLoader ERROR Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [app-context.xml]; nested exception is java.io.FileNotFoun
dException: class path resource [app-context.xml] cannot be opened because it does not exist
这是我的 WEB.XML 文件部分:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/servlet-context.xml classpath:app-context.xml</param-value>
</context-param>
<context-param>
<param-name>applicationContextLocation</param-name>
<param-value>/WEB-INF/source/applicationContext.xml classpath:applicationContext.xml</param-value>
</context-param>
所以这是唯一的错误,应用程序不会在 Apache Tomcat 7.x 中启动。有什么想法或智慧之言吗?请?
更新!
[Thread-18] ContextLoader ERROR Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 14 in XML document from ServletContext resource [/source/app-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 63; The prefix "context" for element "context:component-scan" is not bound.
这是 app-context.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"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-autowire="byName">
<tx:annotation-driven classpath="/Web Pages/" />
<!-- Scans within the base package of the application for @Components to
configure as beans -->
<context:component-scan base-package="com.ccur.mdimgmtsys" />
<!-- Drives transactions using local JPA APIs -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="forceDatabase" />
</bean>
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPost
Processor" />
<bean id="forceService" class="com.force.sdk.connector.ForceServiceConnector">
<property name="connectionName" value="forceDatabase"/>
</bean>
<!--bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.url}"
p:username="${jdbc.username}"
p:password="${jdbc.password}" /-->
<!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
</beans>
谢谢,
彼得