我正在尝试在阿帕奇雄猫和我的sql上运行Web应用程序。早些时候它在预言机11g和野蝇上运行并且工作正常,请在下面找到附加的xml配置文件。提前致谢。
这是我的调度程序-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="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.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<bean id="myBeansValidator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
<mvc:annotation-driven validator="myBeansValidator"/>
<context:component-scan base-package="com.spring.ars"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- <property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property> -->
<property name="prefix">
<value>/</value>
</property>
</bean>
<!-- <context:annotation-config />
<context:component-scan base-package="com.cg"/> -->
<!-- This bean is required to load ORM persistence and related annotations -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<!-- This bean will hold references to our database -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:8080" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
<!-- Spring way of entity manager factory configuration -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="com.spring.ars"/>
<property name="persistenceProviderClass" value="org.hibernate.jpa.HibernatePersistenceProvider"/>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<entry key="hibernate.hbm2ddl.auto" value="update"/>
<entry key="hibernate.show_sql" value="true"/>
</map>
</property>
</bean>
<!-- This bean will handle all transaction within an application -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<!-- This is required to handle transactions via Annotations like @Transactional -->
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
这是我的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>AirlineReservationSystem</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
</jsp-property-group>
</jsp-config>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
堆栈跟踪
该错误似乎表明您的类路径中没有MySQL驱动程序:
无法加载JDBC驱动程序类[com.mysql.jdbc.Driver]
请确保在您的apps WEB-INF/lib文件夹或tomcat lib文件夹中有正确的MySQL连接器/驱动程序:https://dev.mysql.com/downloads/connector/j/5.0.html
如果您没有手动添加它,或者您正在将maven用于项目,则可以将其添加到pom.xml:
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
答
如果您使用的是 mysql,请更改您的Hibernate属性
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="com.spring.ars"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="show_sql">true</prop>
</props>
</property>
</bean>
我使用hibernate 3.2.7和spring 3.2.8。错误是*** **“:创建ServletContext资源[/WEB-INF/Spring-Servlet.xml]中定义的名称为'session Factory'的bean时出错:init方法调用失败;嵌套异常为java.io.FileNotFoundException:ServletContext资源[/resources/hib
问题内容: 问题: 我正在为在类中执行方法创建切入点。该类是控制器类,由注解@Controller表示,因此对于方面所要求的相同,不需要bean。我附加了dispathcher servlet代码,方面和控制器类。有人可以识别出问题所在。 DISPATCHER SERVLET : 方面: 控制器类别: 控制台错误: 问题答案: 这是Spring AOP中的限制。当你使用AspectJ切入点将方面编
http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/
问题内容: 感谢您支持在本地运行该程序包。 现在在本地运行firstapp时遇到异常。 我添加 ,但仅遇到相同的问题。 请建议我必须设置哪些值 问题答案: 您需要按照错误消息的指示将其作为环境变量提供给本地容器。为此,请向环境变量提供相应的参数,就像将真实的XSUAA实例绑定到您的CloudFoundry微服务时一样。对于本地部署,您必须至少具有以下参数,其中该属性需要与JWT的签名匹配。此外,该
我的web.xml 我的调度器-servlet.xml 然后这个 编辑2 我创建了新的clean Spring MVC项目,但问题仍然存在。我想问题可能出在Weblogic上,我会试着重新安装它