SpringMVCDemo icon indicating copy to clipboard operation
SpringMVCDemo copied to clipboard

求助,run500报错

Open c54112189 opened this issue 9 years ago • 2 comments

HTTP Status 500 - Servlet.init() for servlet mvc-dispatcher threw exception

type Exception report

message Servlet.init() for servlet mvc-dispatcher threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

mvc-dispatcher-servlet.xml

<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:mvc="http://www.springframework.org/schema/mvc" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" 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/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd "> <context:component-scan base-package="com.my.controller"/> mvc:default-servlet-handler/

<!-- 开启注解 -->
<mvc:annotation-driven/>

<!--ViewResolver 视图解析器-->
<!--用于支持Servlet、JSP视图解析-->
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    <property name="prefix" value="/WEB-INF/pages/"/>
    <property name="suffix" value=".jsp"/>
</bean>
<!-- 表示JPA Repository所在的包 -->
<jpa:repositories base-package="com.my.repository"/>




<!-- 事务管理 -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>

<!-- 开启事务管理注解 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- 代替persistence.xml -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="defaultPersistenceUnit"/>
    <property name="packagesToScan" value="com.my.model" />
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
    </property>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
            <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/mysystem?useSSL=false</prop>
            <prop key="hibernate.connection.username">root</prop>
            <prop key="hibernate.connection.password">54112189</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.connection.useUnicode">true</prop>
            <prop key="hibernate.connection.characterEncoding">UTF-8</prop>
            <prop key="hibernate.format_sql">true</prop>
            <prop key="hibernate.use_sql_comments">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.connection.autoReconnect">true</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
            <prop key="connection.autoReconnectForPools">true</prop>
            <prop key="connection.is-connection-validation-required">true</prop>

            <prop key="hibernate.c3p0.validate">true</prop>
            <prop key="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</prop>
            <prop key="hibernate.c3p0.min_size">5</prop>
            <prop key="hibernate.c3p0.max_size">600</prop>
            <prop key="hibernate.c3p0.timeout">1800</prop>
            <prop key="hibernate.c3p0.max_statements">50</prop>
            <prop key="hibernate.c3p0.preferredTestQuery">SELECT 1;</prop>
            <prop key="hibernate.c3p0.testConnectionOnCheckout">true</prop>
            <prop key="hibernate.c3p0.idle_test_period">3000</prop>
        </props>
    </property>
</bean>

c54112189 avatar Dec 07 '16 10:12 c54112189

@c54112189 查看一下mvc-dispatcher-servlet.xml 最上头部分是不是少了什么东西

danhops avatar Dec 08 '16 04:12 danhops

自己创建外键,而不是intellij自动创建的BlogsById和userByUserId

Eaphan avatar May 01 '17 08:05 Eaphan