Steps of ssh framework integration

Steps to implement ssh with xml:
1. Configure hibernate
a. Load the relevant jar package (hibernate-core-5.2.12.Final) in pom.xml
b. Configure hibernate.cfg.xml (only responsible for displaying and formatting sql statements , the database connection and mapping files are handed over to spring to implement)
c. Write the hibernate file of the entity class and the entity class (Person.hbm.xml, create tables and columns in the database)
d. In hibernate.cfg.xml Introduce the mapping file Person.hbm.xml (not needed when configuring spring)
e. Test the hibernate framework through junit
1). A new Configuration reads the hibernate configuration file
2). Obtain the SessionFactory through the configuration
3). Through the sessionFactory Get session
4) . Open transaction
5) . Perform operation
6). Commit transaction
7) . Close resource
write picture description here

Note: When using the Hibernate framework alone, you still need to connect the database and the associated mapping file in hibernate.cfg.xml

2. Configure Spring
a. Load Spring-context-4.3.12.RELEASE and spring's dependence on hibernate in pom.xml Spring-orm-4.3.12.RELEASE
b. Build an xml for each package, the most important thing is applicationContext-public.xml
c. Write a db.properties file that connects to the database in the resource file
d. In applicationContext-public.xml
1). Introduce the connection to the database db.properties
write picture description here
2). Configure the data source: Configure the data source The connection pool c3p0, import the c3p0jar package, and assign the value of db.properties to the corresponding place
3). Configure the Sessionfactory, import the data source, load the hibernate configuration file, and load the mapping file (the mapping file corresponding to all entity classes under entity)
4) . Build a transaction manager
5) . Configure the attributes of the transaction
6). Configure the pointcut of the transaction, the corresponding package
write picture description here
e. Write the dao, service layer code, implement the configuration file of each package, and the dao layer refers to sessionFactory, service Layer association dao layer
f. Test spring, read spring's configuration file
ApplicationContext ac=new ClassPathXmlApplicationContext(new String[] {“applicationContext-public.xml”,”applicationContext-service.xml”,”applicationContext-dao.xml”});
得到service层的service
PersonServiceInterface personservice= (PersonServiceInterface) ac.getBean(“PersonserviceImp”);
调用方法

3. Configure struts2
a. Introduce the core package struts2-core-2.5.12, the support package for spring struts2-convention-plugin-2.5.12
b. Configure the action configuration file
c. Configure the Struts2 configuration file and introduce the action
d. Configure web.xml 1. Load Struts2 2. Load spring

Note: Action is called through struts configuration, action is adjusted to service, service is adjusted to dao, and layer-by-layer relationships are interdependent.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325572270&siteId=291194637