2016-10-13 11 views
0

私は、Spring 4.1.1とHibernate 4.3.6を使用してMVCアプリケーションを作成しています。私はsessionfactoryを使いたい。 プロジェクト構造は次のようである:Spring4 MVC with sessionFactory

`<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:util="http://www.springframework.org/schema/util" 
    xsi:schemaLocation="http://www.springframework.org/schema/mvc 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/context http://www.springframework.org/schema/context/spring-context.xsd 
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"> 

    <!-- DispatcherServlet Context: defines this servlet's request-processing 
     infrastructure --> 

    <context:component-scan base-package="com.sat.spring"> 

    </context:component-scan> 


    <!-- Enables the Spring MVC @Controller programming model --> 
    <annotation-driven /> 

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving 
     up static resources in the ${webappRoot}/resources directory --> 
    <resources mapping="/resources/**" location="/resources/" /> 

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources 
     in the /WEB-INF/views directory --> 
    <beans:bean 
     class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <beans:property name="prefix" value="/WEB-INF/views/" /> 
     <beans:property name="suffix" value=".jsp" /> 
    </beans:bean> 


</beans:beans> 

私のweb.xmlがある:私のサーブレット・コンテキストがあるMavenの

enter image description here

を使用して、ここで示されているよう

project structure is like this

依存関係があります通常通り:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    version="2.5" xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:jee="http://www.springframework.org/schema/jee" 
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd 
     http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> 
    <context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>/WEB-INF/spring/root-context.xml</param-value> 
    </context-param> 
    <listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 
    <servlet> 
    <servlet-name>appServlet</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <init-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>appServlet</servlet-name> 
    <url-pattern>/</url-pattern> 
    </servlet-mapping> 

    <welcome-file-list> 
    index.jsp 
    </welcome-file-list> 
</web-app> 

java1.8でtomcat7を実行しています。

問題はroot-context.xmlにあります。 applicationContext.xmlだと思いますが、web.xmlに

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>/WEB-INF/spring/root-context.xml</param-value> 
    </context-param> 

を使用してdifferentleyという名前を付けました。今

編集ルートのcontext.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns="http://www.springframework.org/schema/beans" 
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:c="http://www.springframework.org/schema/c" xmlns:p="http://www.springframework.org/schema/p" 
    xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> 

    <!-- Root Context: defines shared resources visible to all other web components -->  



<context:property-placeholder location="classpath:jdbc.properties" /> 

     <context:component-scan base-package="com.sat.spring"> 
      <context:exclude-filter 

expression="org.springframework.stereotype.Controller" 
      type="annotation" /> 
    </context:component-scan> 


    <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" 
     destroy-method="close"> 
     <property name="driverClassName" value="${jdbc.driverClassName}" /> 
     <property name="url" value="${jdbc.databaseurl}" /> 
     <property name="username" value="${jdbc.username}" /> 
     <property name="password" value="${jdbc.password}" /> 
    </bean> 

    <bean id="sessionFactory" 
     class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> 
     <property name="dataSource" ref="dataSource" /> 
     <property name="packagesToScan" value="com.sat.spring.model" /> 
     <property name="annotatedClasses"> 
      <list> 
       <value>com.sat.spring.model.User</value> 
      </list> 
     </property> 
     <!-- <property name="configLocation"> <props > <prop key="hi"></prop> </props> 
      </property> --> 
     <property name="hibernateProperties"> 
      <props> 
       <prop key="hibernate.hbm2ddl.auto">hibernate.hbm2ddl.auto</prop> 
       <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> 
       <prop key="show_sql">true</prop> 
       <prop key="format_sql">true</prop> 
      </props> 
     </property> 
    </bean> 

    <bean id="transactionManager" 
     class="org.springframework.orm.hibernate4.HibernateTransactionManager"> 
     <property name="sessionFactory" ref="sessionFactory" /> 
    </bean> 

    <bean id="persistenceExceptionTranslationPostProcessor" 
     class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"> 
    </bean> 

    <bean id="userDao" class="com.sat.spring.daoImpl.UserDaoImpl"> 
    <property name="sessionFactory" ref="sessionFactory"></property> 
</bean> 

</beans> 

編集私daoImplは次のとおりです。

public class UserDaoImpl implements UserDao {  

    /* 
     private JdbcTemplate jdbcTemplate; 

     public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { 
      this.jdbcTemplate = jdbcTemplate; 
     }*/ 

     //private SessionFactory sessionFactory;  

     public int save(User user) { 

     /* // saving implementation goes here 
        String query = "insert into student values('" + s.getId() + "','" + s.getName() + "','" + s.getFee() + "','" 
          + s.getDepartment() + "')"; 

        System.out.println("--inside save employee---" + query);*/  

      /*String query = "insert into USER values('" + user.getId() + "','" + user.getName() + "')"; 

      System.out.println("Indise USER" + query); */  

      return 0; 
     }  
    } 

としては、私はウェブで

#jdbc.dialect=org.hibernate.dialect.Oracle10gDialect 
#jdbc.databaseurl=jdbc:oracle:thin:@localhost:1521:xe 
#jdbc.username=admin 
#jdbc.password=admin  

# MYSQL Driver 
jdbc.driverClassName =com.mysql.jdbc.Driver 
jdbc.databaseurl =jdbc:mysql://localhost:3306/uniprojectdb 
jdbc.username=root 
jdbc.password=root 

# postgRdb 
#jdbc.driverClassName =com.postgress.jdbc.Driver 
#jdbc.databaseurl =jdbc:post://localhost:3306/devdb 
#jdbc.username=post 
#jdbc.password=post 
をjdbc.propertiesファイルを追加した提案しました

whe nは私はそれが今私はTomcatのからコンソールに次のエラーを取得する実行します。

Oct 14, 2016 3:54:04 PM org.apache.catalina.core.AprLifecycleListener init 
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_45\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_101/bin/server;C:/Program Files/Java/jre1.8.0_101/bin;C:/Program Files/Java/jre1.8.0_101/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\xampp\mysql\bin\;C:\Python34;C:\Program Files\Java\jdk1.8.0_45\\bin; C:\Program Files\Apache\apache-maven-3.3.3\bin;C:\Program Files\Apache\apache-maven-3.3.3\bin;C:\Program Files (x86)\Common Files\Ulead Systems\MPEG;C:\Program Files (x86)\Skype\Phone\;B:\STS\sts-bundle\sts-3.7.1.RELEASE;;. 
Oct 14, 2016 3:54:04 PM org.apache.tomcat.util.digester.SetPropertiesRule begin 
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:UniversityProject08' did not find a matching property. 
Oct 14, 2016 3:54:04 PM org.apache.tomcat.util.digester.SetPropertiesRule begin 
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SpringMVCJdbc03' did not find a matching property. 
Oct 14, 2016 3:54:05 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["http-bio-8080"] 
Oct 14, 2016 3:54:05 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["ajp-bio-8009"] 
Oct 14, 2016 3:54:05 PM org.apache.catalina.startup.Catalina load 
INFO: Initialization processed in 1111 ms 
Oct 14, 2016 3:54:05 PM org.apache.catalina.core.StandardService startInternal 
INFO: Starting service Catalina 
Oct 14, 2016 3:54:05 PM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47 
Oct 14, 2016 3:54:06 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom 
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [124] milliseconds. 
Oct 14, 2016 3:54:06 PM org.apache.catalina.loader.WebappClassLoader validateJarFile 
INFO: validateJarFile(B:\UniversityProject-STS\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpringMVCJdbc03\WEB-INF\lib\javaee-web-api-7.0.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class 
Oct 14, 2016 3:54:08 PM org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath 
Oct 14, 2016 3:54:08 PM org.apache.catalina.core.ApplicationContext log 
INFO: Initializing Spring root WebApplicationContext 
Oct 14, 2016 3:54:08 PM org.springframework.web.context.ContextLoader initWebApplicationContext 
INFO: Root WebApplicationContext: initialization started 
Oct 14, 2016 3:54:08 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh 
INFO: Refreshing Root WebApplicationContext: startup date [Fri Oct 14 15:54:08 EDT 2016]; root of context hierarchy 
Oct 14, 2016 3:54:08 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
INFO: Loading XML bean definitions from class path resource [spring/application-config.xml] 
Oct 14, 2016 3:54:09 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName 
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver 
Oct 14, 2016 3:54:09 PM org.springframework.web.context.ContextLoader initWebApplicationContext 
INFO: Root WebApplicationContext: initialization completed in 903 ms 
Oct 14, 2016 3:54:09 PM org.apache.catalina.core.ApplicationContext log 
INFO: Initializing Spring FrameworkServlet 'dispatcherServlet' 
Oct 14, 2016 3:54:09 PM org.springframework.web.servlet.DispatcherServlet initServletBean 
INFO: FrameworkServlet 'dispatcherServlet': initialization started 
Oct 14, 2016 3:54:09 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh 
INFO: Refreshing WebApplicationContext for namespace 'dispatcherServlet-servlet': startup date [Fri Oct 14 15:54:09 EDT 2016]; parent: Root WebApplicationContext 
Oct 14, 2016 3:54:09 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-config.xml] 
Oct 14, 2016 3:54:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod 
INFO: Mapped "{[/save],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.save(com.spring.model.Student) 
Oct 14, 2016 3:54:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod 
INFO: Mapped "{[/registered],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.registered(com.spring.model.Student) 
Oct 14, 2016 3:54:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod 
INFO: Mapped "{[/option],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.option(com.spring.model.Student,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap) 
Oct 14, 2016 3:54:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod 
INFO: Mapped "{[/viewstudent],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.viewStudent() 
Oct 14, 2016 3:54:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod 
INFO: Mapped "{[/deleteStudent],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.deletStudent(com.spring.model.Student) 
Oct 14, 2016 3:54:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod 
INFO: Mapped "{[/studentform],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.showform() 
Oct 14, 2016 3:54:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod 
INFO: Mapped "{[/deletedStudent],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.dele(com.spring.model.Student) 
Oct 14, 2016 3:54:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod 
INFO: Mapped "{[/editStudent],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.edit(com.spring.model.Student) 
Oct 14, 2016 3:54:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod 
INFO: Mapped "{[/edit],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.editStudent(int,com.spring.model.Student,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap) 
Oct 14, 2016 3:54:10 PM org.springframework.web.servlet.DispatcherServlet initServletBean 
INFO: FrameworkServlet 'dispatcherServlet': initialization completed in 967 ms 
Oct 14, 2016 3:54:12 PM org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath 
Oct 14, 2016 3:54:12 PM org.apache.catalina.core.ApplicationContext log 
INFO: Initializing Spring root WebApplicationContext 
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started 
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Fri Oct 14 15:54:13 EDT 2016]; root of context hierarchy 
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root-context.xml] 
INFO : org.springframework.context.support.PropertySourcesPlaceholderConfigurer - Loading properties file from class path resource [jdbc.properties] 
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 
WARN : org.hibernate.cfg.SettingsFactory - Unrecognized value for "hibernate.hbm2ddl.auto": hibernate.hbm2ddl.auto 
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 2697 ms 
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization started 
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri Oct 14 15:54:15 EDT 2016]; parent: Root WebApplicationContext 
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml] 
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 
Oct 14, 2016 3:54:15 PM org.apache.catalina.core.ApplicationContext log 
INFO: Initializing Spring FrameworkServlet 'appServlet' 
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[//],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sat.spring.controller.HomeController.home() 
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[//home],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sat.spring.controller.HomeController.home(java.util.Locale,org.springframework.ui.Model) 
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/login],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.sat.spring.controller.LoginController.login() 
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/submit],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sat.spring.controller.LoginController.saveOrUpdateUser(com.sat.spring.model.User,org.springframework.validation.BindingResult,org.springframework.ui.Model) 
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri Oct 14 15:54:15 EDT 2016]; parent: Root WebApplicationContext 
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri Oct 14 15:54:15 EDT 2016]; parent: Root WebApplicationContext 
INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0' 
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization completed in 729 ms 
Oct 14, 2016 3:54:16 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["http-bio-8080"] 
Oct 14, 2016 3:54:16 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["ajp-bio-8009"] 
Oct 14, 2016 3:54:16 PM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 11403 ms 
Oct 14, 2016 3:54:25 PM org.apache.catalina.core.StandardWrapperValve invoke 
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/spring] threw exception [Request processing failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [WEB-INF/spring/root-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/spring/root-context.xml] cannot be opened because it does not exist] with root cause 
java.io.FileNotFoundException: class path resource [WEB-INF/spring/root-context.xml] cannot be opened because it does not exist 
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251) 
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127) 
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93) 
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) 
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452) 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) 
    at com.sat.spring.controller.LoginController.saveOrUpdateUser(LoginController.java:43) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:497) 
    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) 
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) 
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) 
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:781) 
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:721) 
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) 
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) 
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) 
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) 
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) 
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) 
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 

INFO : org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org[email protected]124d1985: startup date [Fri Oct 14 15:54:25 EDT 2016]; root of context hierarchy 
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [WEB-INF/spring/root-context.xml] 

おかげで...

+0

あなたが見ています春のブートと春の初期化で?春のブートは上記のすべての構成を「ブートストラップ」することができ、開発に直ちに進むことができます。また、そこにはたくさんのガイドがあり、助けてくれます。 http://projects.spring.io/spring-boot/ – RuntimeBlairror

+0

'$ {hibernate.dialect} 'の値をどこかに定義しましたか?私はあなたが投稿したものでそれを見つけることができません。 '$ {jdbc.driverClassName}'、 '$ {jdbc.url}'、 '$ {jdbc.user}'などの場合もそうです。そうでない場合は、これらのプロパティ変数に有効な値を指定する必要があります。 –

答えて

0

問題は、あなたのデータソースの構成です。プロパティプレースホルダの値が解決されていません。 org.hibernate.engine.jdbc.internal.JdbcServicesImplを - HHH000342を::WARN

にここでエラーをチェックし、メタデータを照会し、接続を取得できませんでした: '$ {jdbc.driverClassName}' JDBCドライバクラスをロードできません

あなたは、プロパティplacheolder値は

<context:property-placeholder location="classpath:jdbc.properties"/> 
を例えば含むプロパティファイルを定義する必要が

jdbc.propertiesは値

を含むクラスパスのルートになりますorg.hibernate.HibernateException:あなたのデータソースの設定でのエラーのため、Hibernateはエラー

によって引き起こさに、したがって使用する方言を判断するために、接続を取得することはできませんのでDialectResolutionInfoへのアクセスはnullにすることはできません

+0

src/main/resourcesにjdbc.propertiesファイルを追加しました。上記のエラーが発生しました。... – javaz

+0

データベースに接続するには、mysql JDBCドライバが必要です。あなたのpom.xmlにfolowing依存関係を追加します mysqlの のmysql-コネクタ-javaの 5.1.40

+0

は、JDBC – javaz

関連する問題