SSJ (Spring + springMVC + JPA) configuration roadmap process

Use tools IDEA

1. create a new maven project, configured project file structure

 

 

 

 Configuration considerations:

1. connect to the database

Need to connect to the database connection properties (database address, account number, password, driver information), it will create a jdbc. The Properties file in the resources file, then the configuration file content.

 

      There is a connection then start the connection, appllocationContext.xml configuration database connection

  

 

  Then built the table, because it is jpa so first build a User objects, add jpa annotations

@Entity // build relationships with database

@Table // set the table

@ Id // set the primary key

@GeneratedValue //自增

 

   Set these, there are sure to be scanned notes, since the use jpa it will certainly be configured EntityManagerFactoryBean , then went appllocationContext.xml configuration EntityManagerFactoryBean

 

 

  

 

   These configurations good to test the test to establish a test class to begin testing next file

  

 

   Run testJpa () can print address that success.

 

 

 

  

 

   Or to build a database to see the user table did.

The connection is completed

 

 

Configuration considerations:

1. connect to the database

Need to connect to the database connection properties (database address, account number, password, driver information), it will create a jdbc. The Properties file in the resources file, then the configuration file content.

 

There is a connection then start the connection, appllocationContext.xml configuration database connection

 

 

Then built the table, because it is jpa so first build a User objects, add jpa annotations

@Entity // build relationships with database

@Table // set the table

@ Id // set the primary key

@GeneratedValue //自增

 

 

设置好这些,有注解肯定要扫描,既然要用jpa那肯定要配置EntityManagerFactoryBean,然后又去appllocationContext.xml配置EntityManagerFactoryBean

 

Guess you like

Origin www.cnblogs.com/bigbigxiao/p/11811724.html