Code ví dụ Spring MVC + Hibernate Session + Maven + MySQL + Eclipse

Code ví dụ Spring MVC + Hibernate Session + Maven + MySQL + Eclipse

Ở bài này mình sẽ kết hợp Spring MVC với Hibernate để thực hiện ví dụ thêm, sửa, xóa dữ liệu với database.

(Bài này sử dụng Hibernate Session nhé, các bạn có thể xem thêm ví dụ Spring MVC với Hibernate EntityManger)

(Xem lại: So sánh Hibernate Session với JPA EntityManager)

Các công nghệ sử dụng:

Tạo Database

Tạo database demo-spring-mvc-hibernate với table customer

CREATE SCHEMA `demo-spring-mvc-hibernate` ;
CREATE TABLE `demo-spring-mvc-hibernate`.`customer` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(45) NULL,
  `address` VARCHAR(255) NULL,
  PRIMARY KEY (`id`));

Code ví dụ Spring MVC + Hibernate + Maven + MySQL + Eclipse

Tạo maven project:

Code ví dụ Spring MVC + Hibernate Session + Maven + MySQL + Eclipse stackjava.com

Thư viện sử dụng:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>stackjava.com</groupId>
  <artifactId>SpringMVC-Hibernate</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <properties>
    <spring.version>5.0.2.RELEASE</spring.version>
    <hibernate.version>5.2.12.Final</hibernate.version>
    <jstl.version>1.2</jstl.version>
  </properties>
  <dependencies>

    <!-- Spring Web -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <!-- Hibernate -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>${hibernate.version}</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>${hibernate.version}</version>
    </dependency>
    <dependency>
      <groupId>commons-dbcp</groupId>
      <artifactId>commons-dbcp</artifactId>
      <version>1.4</version>
    </dependency>
    <!-- MySQL -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.45</version>
    </dependency>

    <!-- jsp-api -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.0</version>
      <scope>provided</scope>
    </dependency>

    <!-- jstl -->
    <dependency>
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>${jstl.version}</version>
    </dependency>
  </dependencies>
</project>

 

File thông tin kết nối database:

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/demo-spring-mvc-jdbc
jdbc.username=root
jdbc.password=admin1234

File cấu hình hibernate:

hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.hibernate.current_session_context_class=thread
hibernate.show_sql=true

File Spring config:

<?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:mvc="http://www.springframework.org/schema/mvc"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.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-4.3.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">

  <context:annotation-config />
  <context:component-scan base-package="stackjava.com.springmvchibernate" />
  <bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix">
      <value>/WEB-INF/views/jsp/</value>
    </property>
    <property name="suffix">
      <value>.jsp</value>
    </property>
  </bean>

  <bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
      <value>classpath:jdbc.properties</value>
    </property>
  </bean>

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

  <tx:annotation-driven transaction-manager="transactionManager" />

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


  <bean id="sessionFactory"
    class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="packagesToScan" value="stackjava.com.springmvchibernate.entities" />
    <property name="hibernateProperties" value="classpath:hibernate.properties" />
  </bean>


</beans>

File entity:

package stackjava.com.springmvchibernate.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

@Entity
@Table(name = "customer")
public class Customer {
  @Id
  @Column(name = "id")
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private int id;

  @Column(name = "name")
  private String name;

  @Column(name = "address")
  private String address;

  @Version
  @Column(name = "version")
  private Integer version;

  public Customer() {
  }

  // getter - setter

}

File Controller:

package stackjava.com.springmvcjdbc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import stackjava.com.springmvcjdbc.entities.Customer;
import stackjava.com.springmvcjdbc.service.CustomerService;

@Controller
public class CustomerController {

  @Autowired
  private CustomerService customerService;

  @RequestMapping(value={"/", "/customer-list"})
  public String listCustomer(Model model) {
    model.addAttribute("listCustomer", customerService.findAll());
    return "customer-list";
  }

  @RequestMapping("/customer-save")
  public String insertCustomer(Model model) {
    model.addAttribute("customer", new Customer());
    return "customer-save";
  }

  @RequestMapping("/customer-view/{id}")
  public String viewCustomer(@PathVariable int id, Model model) {
    Customer customer = customerService.findById(id);
    model.addAttribute("customer", customer);
    return "customer-view";
  }
  
  @RequestMapping("/customer-update/{id}")
  public String updateCustomer(@PathVariable int id, Model model) {
    Customer customer = customerService.findById(id);
    model.addAttribute("customer", customer);
    return "customer-update";
  }

  @RequestMapping("/saveCustomer")
  public String doSaveCustomer(@ModelAttribute("Customer") Customer customer, Model model) {
    customerService.save(customer);
    model.addAttribute("listCustomer", customerService.findAll());
    return "customer-list";
  }

  @RequestMapping("/updateCustomer")
  public String doUpdateCustomer(@ModelAttribute("Customer") Customer customer, Model model) {
    customerService.update(customer);
    model.addAttribute("listCustomer", customerService.findAll());
    return "customer-list";
  }
  
  @RequestMapping("/customerDelete/{id}")
  public String doDeleteCustomer(@PathVariable int id, Model model) {
    customerService.delete(id);
    model.addAttribute("listCustomer", customerService.findAll());
    return "customer-list";
  }
}

Lưu ý, khi delete thì người ta hiếm khi dùng method GET. mà sẽ đưa nó vào form và sử dụng method POST.

Ở đây mình để method GET để cho ví dụ dễ hiểu và ngắn gọn.

File Service:

package stackjava.com.springmvcjdbc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import stackjava.com.springmvcjdbc.dao.CustomerDAO;
import stackjava.com.springmvcjdbc.entities.Customer;

@Service
@Transactional
public class CustomerService {

  @Autowired
  private CustomerDAO customerDAO;
  
  public List<Customer> findAll() {
    return customerDAO.findAll();
  }

  public Customer findById(int id) {
    return customerDAO.findById(id);
  }
  
  public void save(Customer customer){
    // validate business
    customerDAO.save(customer);
  }

  public void update(Customer customer){
    // validate business
    customerDAO.update(customer);
  }
  
  public void delete(int id){
    // validate business
    customerDAO.delete(id);
  }
}

File DAO:

package stackjava.com.springmvchibernate.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import stackjava.com.springmvchibernate.entities.Customer;

@Repository(value = "customerDAO")
@Transactional(rollbackFor = Exception.class)
public class CustomerDAO {

  @Autowired
  private SessionFactory sessionFactory;

  public void save(final Customer customer) {
    Session session = this.sessionFactory.getCurrentSession();
    session.save(customer);
  }

  public void update(final Customer customer) {
    Session session = this.sessionFactory.getCurrentSession();
    session.update(customer);
  }

  public Customer findById(final int id) {
    Session session = this.sessionFactory.getCurrentSession();
    return session.get(Customer.class, id);
  }

  public void delete(final Customer customer) {
    Session session = this.sessionFactory.getCurrentSession();
    session.remove(customer);
  }

  public List<Customer> findAll() {
    Session session = this.sessionFactory.getCurrentSession();
    return session.createQuery("FROM Customer", Customer.class).getResultList();
  }
}

 

File View:

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>Helo Spring MVC + JDBC</title>
<style>
table, th, td {
  border: 1px solid black;
}
td {
  padding-right: 30px;
}
</style>
</head>
<body>
  <c:url value="/customer-save" var="urlSave"/>
  <c:url value="/customer-view/" var="urlView"/>
  <c:url value="/customer-update/" var="urlUpdate"/>
  <c:url value="/customerDelete/" var="urlDelete"/>
  <h1>List Customer:</h1>
  <a href="${urlSave}">Add Customer</a>
  <br />
  <br />


  <table>
    <tr>
      <th>Id</th>
      <th>Name</th>
      <th>Address</th>
      <th>View</th>
      <th>Edit</th>
      <th>Delete</th>
    </tr>
    <c:if test="${not empty listCustomer}">
      <c:forEach var="customer" items="${listCustomer}">
        <tr style="border: 1px black solid">
          <td>${customer.id}</td>
          <td>${customer.name}</td>
          <td>${customer.address}</td>
          <td> <a href="${urlView}/${customer.id}">View</a></td>
          <td> <a href="${urlUpdate}/${customer.id}">Edit</a></td>
          <td> <a href="${urlDelete}/${customer.id}">Delete</a></td>
        </tr>
      </c:forEach>
    </c:if>
  </table>

</body>
</html>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<html>
<head>
<title>Helo Spring MVC + JDBC</title>
</head>
<body>
  <a href="<c:url value="/customer-list" />" >List Customer</a><br />

  <h1>Add new Customer:</h1>
  <c:url value="/saveCustomer" var="saveCustomer"/>
  <form:form action="${saveCustomer}" method="POST"
    modelAttribute="customer">
    	Name: <form:input path="name" /> <br/> <br/>
    	Address: <form:input path="address" /> <br/> <br/>
    <button type="submit">Submit</button>
  </form:form>

</body>
</html>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<html>
<head>
<title>Helo Spring MVC + JDBC</title>
</head>
<body>
  <a href="<c:url value="/customer-list" />">List Customer</a>
  <br />

  <h1>Edit Customer:</h1>
  <c:url value="/updateCustomer" var="updateCustomer" />
  <form:form action="${updateCustomer}" method="POST" modelAttribute="customer">
      Id: <form:input path="id" readonly="true" /> <br/> <br/>
    	Name: <form:input path="name" /> <br/> <br/>
    	Address: <form:input path="address" /> <br/> <br/>
    <button type="submit">Submit</button>
  </form:form>

</body>
</html>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>Helo Spring MVC + JDBC</title>
</head>
<body>
  <a href="<c:url value="/customer-list" />" >List Customer</a><br />
  <h1>View Customer:</h1>	
  Customer ID: ${customer.id} <br/>
  Customer Name: ${customer.name} <br/>
  Customer Address: ${customer.address} <br/>
</body>
</html>

Demo:

Thêm mới customer

Code ví dụ Spring MVC + Hibernate + Maven + MySQL + Eclipse Code ví dụ Spring MVC + Hibernate + Maven + MySQL + Eclipse

View Customer:

Code ví dụ Spring MVC + Hibernate + Maven + MySQL + Eclipse Code ví dụ Spring MVC + Hibernate + Maven + MySQL + Eclipse

Update customer:

Code ví dụ Spring MVC + Hibernate + Maven + MySQL + Eclipse Code ví dụ Spring MVC + Hibernate + Maven + MySQL + Eclipse

Delete customer:

Code ví dụ Spring MVC + Hibernate + Maven + MySQL + Eclipse Code ví dụ Spring MVC + Hibernate + Maven + MySQL + Eclipse

Code ví dụ Spring MVC + Hibernate + Maven + MySQL + Eclipse

Okay, Done!

Download code ví dụ trên tại đây

 

References:

https://docs.spring.io/spring/docs/current/spring-framework-reference/data-access.html

21 thoughts on “Code ví dụ Spring MVC + Hibernate Session + Maven + MySQL + Eclipse

  • mình đang viết tiếp về spring + thymeleaf.
    Bạn có thể đăng ký email để nhận thông báo. Vì mình vẫn đang trong quá trình biên soạn nên thứ tự các bài nó hơi lộn xộn chút =))
    Thanks bạn.

  • Cho mình hỏi trong trường hợp mình xóa một bản ghi, nếu xảy ra exception và transaction thực hiện rollback, giá trị nào sẽ được trả về từ hàm được đánh dấu annotation Transactional?

    • Không quan trọng là hàm của bạn được đánh dấu annotation Transactional hay không. Khi xảy ra exception thì nó sẽ không trả về giá trị nào cả.
      Bạn có thể thực hiện bắt xem exception nào đã xảy ra và thực hiện tiếp điều mình muốn (ví dụ hiện thông báo lỗi, nguyên nhân lỗi…)

    • Bạn để ý trong controller:
      @RequestMapping(value={“/”, “/customer-list”})
      public String listCustomer(Model model) {
      model.addAttribute(“listCustomer”, customerService.findAll());
      return “customer-list”;
      }
      tức là path / và /customer-list đều hiện trang customer-list.jsp
      Bạn xem lại nó đúng là @RequestMapping(value={“/”, “/customer-list”}) hay đang để @RequestMapping( “/customer-list”)

  • anh ơi tại sao khi em run lên thì toàn bị lỗi server k khởi động được.
    nếu bỏ dependency này ra thì được:

    org.springframework
    spring-orm
    ${spring.version}

    ——–Errors:
    java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at java.util.concurrent.FutureTask.report(Unknown Source)
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:917)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:760)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:625)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
    Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:925)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:868)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    … 6 more

    • mình chưa gặp lỗi này lần nào, bạn thử vào thư mục m2/repository rồi xóa thư viện đó đi rồi import lại maven để nó tải lại thư viện đó xem còn lỗi không.

  • Hi a @cuongth
    E làm theo bài viết của a, sau khi chạy với apache tomcat 7.0 thì xuất hiện lỗi 404 với log là:
    Aug 08, 2018 10:29:13 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
    WARNING: No mapping found for HTTP request with URI [/SpringMVC-Hibernate/] in DispatcherServlet with name ‘spring-config’
    Mong anh giúp đỡ

    • Bạn xem content root của bạn là gì?
      Thường là trùng với tên project nhé, hoặc có thểm xem bằng cách chuột phải vào project -> properties -> web project setting.
      Ví dụ bạn tạo project tên là xxx thì mặc định content root của bạn là xxx -> trang web của bạn sẽ hoạt động ở url:
      localhost:8080/xxx

    • Bạn cho mình 1 tình huống áp dụng cụ thể được không? vì trường hợp kết nối tới số lượng lớn database như thế thì thông tin kết nối database sẽ để trong 1 database chính hoặc 1 file riêng.

      Còn nếu chỉ có 2,3 database thì bạn có thể tạo nhiều bean dataSource với các tham số khác nhau tương ứng cho từng database là được

  • mình chay bị lỗi này là sao bạn,mình xài intellij IDE
    Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection

  • Chào bạn, mình chạy bị lỗi này là sao vậy bạn?? giúp mình với :((.
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘customerController’: Unsatisfied dependency expressed through field ‘customerService’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’: Failed to introspect bean class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/hibernate/boot/MetadataSources

    • bạn bị lỗi maven rồi. bạn thử vào thư mục m2/repository rồi xóa thư viện đó đi rồi import lại maven để nó tải lại thư viện đó xem còn lỗi không.
      đồng thời check lại file jdbc.properties xem đã đúng thông tin kết nối tới database của bạn chưa.

  • Error creating bean with name ‘customerController’: Unsatisfied dependency expressed through field ‘customerService’; lỗi gì mà sửa mãi không được vậy anh..sửa cả thư viện maven rồi cũng ko được

    • Nó báo lỗi không inject được bean customerSerivce kìa bạn. Mà customerService của mình đang rất đơn giản, nó chỉ goi lại customerDAO thôi, bạn check lại thông tin connect database đã đúng chưa

  • em chạy nó báo lỗi vậy sửa ạ

    HTTP Status 500 – Internal Server Error

    Type Exception Report

    Message Servlet.init() for servlet spring-config threw exception

    Description The server encountered an unexpected condition that prevented it from fulfilling the request.

    Exception
    javax.servlet.ServletException: Servlet.init() for servlet spring-config threw exception
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

    Root Cause
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘customerController’: Unsatisfied dependency expressed through field ‘customerService’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’: Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] from ClassLoader [WebappClassLoader
    context: /SpringMVC-Hibernate
    delegate: false
    repositories:
    /WEB-INF/classes/
    ———-> Parent Classloader:
    java.net.URLClassLoader@7440e464
    ]
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586)
    org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
    org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:758)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:676)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:642)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:690)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:558)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:499)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:172)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

DMCA.com Protection Status stackjava.com