The first database demo that was developed under IntelliJ with Java Spring + Mysql + Hibernate

Source: Internet
Author: User
Tags aop mysql login

Get ready:

1, install MySQL.

2, install MAVEN.

3. Prepare your IDE (eclipse, or IntelliJ).

Business:

Building projects with the Spring framework is the first thing to know about what AOP and Di are. (Self-check)

There are two types of questions in the implementation process.

1. The first is how spring is implemented we do not have a new bean but can get some bean components

2, Hibernate and DAO is what, Daosupport is what, why have daoimpl.impl inside of Templete is what.

The first kind of problem comes from not understanding AOP, and Di. In spring, a bean object can be defined in spring's context description file, which is a lot of the XML files we see. The XML file describes what the attributes are in each bean. The type source of the property, and so on. When these things are described, spring's context is searched one by one in our initialization of its XML. It is possible to initialize the bean inside when it is being used, so we can get the bean object directly in the context through the ID of a bean without having to initialize it.

The second category is some knowledge of the database in spring:

Keyword Explanation:

Hibernate is a third-party class library that uses objects to access the database, and of course it is well-known that we can establish a connection between the table and the entity class simply by configuring the XML for the relationship between the entity class and the table in the database.

DAO is our own definition of what we want to do with the database in the project. Templete is a tool for adding and removing changes in spring. We define a DAO interface and use a class to implement this DAO interface is what we see Daoimpl, and Daoimpl may inherit a daosupport such thing, this thing will help us to build a good initialization and configure templete this tool. All we have to do is call this tool and we can do what we have to do (the method defined in DAO)

In a nutshell: Daoimpl inherits Daosupport and calls Templete to implement the data business in DAO.

Reference: https://www.mkyong.com/spring/maven-spring-hibernate-mysql-example/

I also wrote it as follows: http://download.csdn.net/detail/zrical/9735317 in this link can be downloaded

The prerequisites to run

1. You created a local MySQL database and created a table in it:

CREATETABLE' Mkyong`.' Stock`(' stock_id`Int(10) unsignedNotNullAuto_increment,' Stock_code`varchar(10)NotNull,' Stock_name`varchar(20)NotNull,PRIMARYKEY(' stock_id`)USINGBTREE,UNIQUEKEY' Uni_stock_name`(' Stock_name ' ) unique key  ' Uni_stock_id '  ' Stock_code ' using btree) engine=innodb auto_increment=11 default  Charset=utf8       

2. Change the configuration of the database connection in XML, change the database name and table name to the database and table you created. Change your MySQL login password.

3. Your MySQL will start up

Then it's almost ready to run.

The first database demo that was developed under IntelliJ with Java Spring + Mysql + Hibernate

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.