spring - 当我尝试在服务器(tomcat)上运行我的 spring 应用程序时,会出现此错误消息:
问题描述
安慰
错误:org.springframework.web.context.ContextLoader-上下文初始化失败.40/wtpwebapps/EBoutiqueV3/WEB-INF/classes/applicationContext.xml];
/EBoutiqueV3/src/main/resources/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"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:s="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<bean id="datasource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/sid_eboutique"></property>
<property name="username" value="root"></property>
<property name="password" value=""></property>
</bean>
<bean id="persistenceUnitManager"
class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<property name="defaultDataSource" ref="datasource"></property>
<property name="persistenceXmlLocations">
<list>
<value>classpath*:META-INF/persistence.xml</value>
</list>
</property>
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitManager" ref="persistenceUnitManager"></property>
<property name="persistenceUnitName" value="UP_BOUTIQUE"></property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<context:annotation-config></context:annotation-config>
<bean id="dao" class="org.sid.eboutique.dao.BoutiqueDaoImpl"></bean>
<bean id="metier" class="org.sid.eboutique.metier.BoutiqueMetierImpl">
<property name="dao" ref="dao"></property>
</bean>
<s:http>
<s:intercept-url pattern="/adminProd/**" access="ROLE_ADMIN_PROD"/>
<s:intercept-url pattern="/adminCat/**" access="ROLE_ADMIN_CAT"/>
<s:form-login login-page="/login" default-target-url="/adminProd/index"
authentication-failure-url="/login" />
<s:logout logout-success-url="/logout" />
</s:http>
<s:authentication-manager>
<s:authentication-provider>
<s:password-encoder hash="md5"></s:password-encoder>
<s:jdbc-user-service data-source-ref="datasource"
users-by-username-query="select username, password, active from users where username=?"
authorities-by-username-query="select u.username, r.roleName from users u, role r
where u.id_user = r.id_user and u.username =? " />
</s:authentication-provider>
</s:authentication-manager>
<!-- Tiles View Resolver Configuration -->
<bean id="tilesViewresolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView">
</property>
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<value>/WEB-INF/tiles/tiles.xml</value>
</property>
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="10000000"></property>
</bean>
<context:component-scan base-package="org.sid">
<context:include-filter type="aspectj" expression="org.sid.*" />
</context:component-scan>
</beans>
/EBoutiqueV3/src/main/resources/META-INF/persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd ">
<persistence-unit name="UP_BOUTIQUE" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
</properties>
</persistence-unit>
</persistence>
解决方案
推荐阅读
- xml - 无法使用 XSLT 从 xml 中选择属性
- bash - grep 并过滤掉文件中的值
- r - 如何按日期分组并将循环输出保存到新变量中?
- kubernetes - 新手 - 更改了 yaml - 如何用相同的方式更新 k8s 集群
- javascript - 即使使用了一个组,SignalR 也会向所有人广播
- python - 只有当它们高于某些值时,如何对列值进行数学运算,否则在熊猫中将其设置为 1?
- python - 如何使用 html 文件在 django 中显示 ChoiceField?
- react-native - 使用 expo 在 react-native 中打开 PDF 文件
- android - 用户未点击软键盘的确认按钮时获取 EditText 内容
- php - 条件 SQL 查询 [VueJS]