Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the Maven SSM like in Java

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What is the Maven SSM in Java? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

SSM

@ Controller,@Service is essentially @ Component, which is used to put the new object into the Spring container.

Controller layer

@ Controller// controller layer specific annotations @ RequestMapping ("/ student") public class StudentController {@ Autowired private IStudentService studentService; @ RequestMapping ("/ selectAll") @ ResponseBody public List selectAll () {System.out.println ("StudentController.selectAll"); List list = studentService.selectAll (); return list;}}

Service layer

Public interface IStudentService {public List selectAll (); @ Service// service layer specific annotations public class StudentServiceImpl implements IStudentService {@ Autowired private IStudentMapper studentMapper; @ Override public List selectAll () {System.out.println ("StudentServiceImpl.selectAll"); return studentMapper.selectAll ();}}

Dao layer, where the dao layer is often written as mapper, using .xml files instead of the original DaoImpl, only need to write namespace,sql statements, etc., very convenient.

Public interface IStudentMapper {public List selectAll ();} SELECT `id`, `name`, `age`, `gender`, `class_ id` FROM `student` Maven what is maven

Is an open source project under apache, is pure java development, and can only be used to manage java projects.

Maven benefits, why use Maven

1. Dependency management:

Is the unified management of the jar package, which can save space.

Analysis: why is the Maven project so small?

There is no jar package.

The required jar is managed by Maven and stored in the warehouse of Mavne.

2. One-click construction

Mavne allows you to run a java project away from Eclipse and Tomcat (because Maven itself comes with the tomcat plug-in).

Clear (mvn clean)

Compile (mvn compile)

Test (mvn test)

Run (mvn tomcat:run)

Package (mvn package)

Deployment

If the project is javase, the export is a jar package.

If it is a web project, it exports a war package.

3. Cross-platform

4. When applied to large-scale projects, the development efficiency can be improved.

Such as e-commerce system: user management module, order management module, payment management module.

Maven can be developed in modules.

These modules are developed by different teams.

If the code of the order module requires the code of the user module, the order module needs the code of the user module in the original way.

You also need to compile this code at run time, which is very inconvenient.

Each module is stored in other modules as a jar package, so you don't need to know the specific code or compile it, just call the code in the jar package directly.

It's not war that relies on management, it's jar.

Three kinds of warehouses

1. Local warehouse (self-maintenance).

2. Remote warehouse (private server: private server), maintained by the company. (this warehouse is not necessarily owned by the company.)

3. Central warehouse, maintained by maven team.

Coordinate concept

GroupId: company name

ArtifactId: project name or module name

Version: version number

Coordinates = groupId+artifactId+version

After reading the above, have you mastered the method of Maven SSM in Java? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report