当前位置: 首页 > wzjs >正文

绥化安达网站建设设计名字的网站

绥化安达网站建设,设计名字的网站,网页设计与制作实训报告心得体会2000字,北京今朝装饰公司官网目录 一、前言 二、项目结构 三、初始化项目 四、SpringBoot项目集成Mybatis编写接口 五、代码仓库 一、前言 构建一个基于Spring Boot框架的现代化Web应用程序,以满足[公司/组织名称]对于[业务需求描述]的需求。通过利用Spring Boot简化企业级应用开发的优势…

目录

一、前言

二、项目结构

三、初始化项目

四、SpringBoot项目集成Mybatis编写接口

五、代码仓库


一、前言

构建一个基于Spring Boot框架的现代化Web应用程序,以满足[公司/组织名称]对于[业务需求描述]的需求。通过利用Spring Boot简化企业级应用开发的优势,实现一个高效、可扩展且易于维护的应用系统。

  • 提高效率:通过集成微服务架构模式,减少系统的复杂度,并加速开发周期。
  • 增强用户体验:提供一个响应迅速、界面友好且功能齐全的用户交互平台。
  • 确保数据安全:实施严格的数据保护措施,保障用户信息安全。
  • 支持跨平台访问:设计RESTful API接口,确保应用程序可以在多种设备上无缝运行。

二、项目结构

项目遵循Maven标准目录布局,主要分为以下几个模块:

  • core:包含业务逻辑层代码。

  • exception:包含各个异常捕捉类。

  • mapper:定义了数据访问对象,用于与数据库交互。

  • service:提供了对外的服务接口。

  • entity:项目实体类

  • controller:处理HTTP请求并调用相应的服务方法。

  • config:存放所有配置文件。

  • test:单元测试及集成测试代码。

  • common:公共类,统一包装。

三、初始化项目

点击新建项目

根据以下图片创建

选择框架依赖

设置文件编码统一为UTF-8

检查Maven构建项目的目录

以下pom.xml文件已经加载,如果没有出现xml文件则需右键点击构建Maven项目即可

application配置文件,因为框架中选择了数据库,使用需要配置数据库,mybatis依赖在后续集成时,可添加以下配置。

# 应用服务 WEB 访问端口
server:port: 9090
#数据库配置
spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverusername:  rootpassword: 123456//(本机数据库密码)url: jdbc:mysql://localhost:3306/userdb//(本机数据库)
//#mybatis依赖
//# mybatis:
//# MyBatis Configuration确保在 application.properties 或 application.yml 文件中指定了正确的映射文件路径// mapper-locations: classpath:mapper/*.xml// configuration://   log-impl: org.apache.ibatis.logging.stdout.StdOutImpl//   map-underscore-to-camel-case: true

到此项目配置成功!

四、SpringBoot项目集成Mybatis编写接口

接下来我们将实现一个简单的用户列表获取接口,以下是具体的分层结构

Result类

package com.example.springboot.common;
//统一设置包装类,返回数据的类型
public class Result {private Integer code;  // 状态码private String message;  // 消息private Object data;  // 数据// 默认成功的构造方法// 成功但没有数据时的静态方法public static Result success() {Result result =new Result();result.setCode(200);result.setMessage("请求成功");return result;}public static Result success(Object data) {Result result =success();result.setData(data);return result;}// 静态方法用于快速构建结果对象public static Result error() {Result result =new Result();result.setCode(500);result.setMessage("请求成功");return result;}// Getters and Setterspublic Integer getCode() {return code;}public void setCode(Integer code) {this.code = code;}public String getMessage() {return message;}public void setMessage(String message) {this.message = message;}public Object getData() {return data;}public void setData(Object data) {this.data = data;}// 打印结果对象信息的方法(可选)@Overridepublic String toString() {return "Result{" +"code=" + code +", message='" + message + ''' +", data=" + (data != null ? data.toString() : "null") +'}';}
}

UserController控制层提供访问接口localhost:9090/user/selectAll

package com.example.springboot.controller;import com.example.springboot.common.Result;
import com.example.springboot.service.UserService;
import com.example.springboot.entity.user;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.List;@RestController
@RequestMapping("/user")
public class UserController {
@Resourceprivate UserService userservice;
//查询所有用户@GetMapping("/selectAll")public Result selectAll(){List<user>list=userservice.selectAll();return  Result.success(list);}
}

User类实体类,需要对应相应数据库

package com.example.springboot.entity;import org.apache.ibatis.annotations.Mapper;//entity包里面装着实体类
public class user {private  String userID;private  String userName;private  String userPassword;private  Integer userAge;public String getUserID() {return userID;}public void setUserID(String userID) {this.userID = userID;}public String getUserName() {return userName;}public void setUserName(String userName) {this.userName = userName;}public String getUserPassword() {return userPassword;}public void setUserPassword(String userPassword) {this.userPassword = userPassword;}public Integer getUserAge() {return userAge;}public void setUserAge(Integer userAge) {this.userAge = userAge;}}

UserMapper接口连接数据库操作,在对应的Mybastis映射文件下,上文中的application配置文件中的路径一致,添加UserMapper.xml文件

package com.example.springboot.mapper;import com.example.springboot.entity.user;import java.util.List;//数据库userBean层
public interface UserMapper {List<user> selectAll();
}

安装插件MyBatisX可快速查看映射方法

userMapper.xml配置文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.example.springboot.mapper.UserMapper"><!-- SQL 映射语句将在此处定义 --><select id="selectAll" resultType="com.example.springboot.entity.user">SELECT * FROM user_list</select>
</mapper>

UserService类,提供项目业务逻辑层

package com.example.springboot.service;import com.example.springboot.mapper.UserMapper;
import com.example.springboot.entity.user;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;import java.util.List;//业务逻辑层
@Service
public class UserService {@Resourceprivate UserMapper userMapper;public List<user> selectAll() {List<user> list = userMapper.selectAll();return list;}
}

在启动文件中添加扫描路径

@MapperScan("com.example.springboot.mapper")

点击运行即可!欢迎大家一起学习讨论,批评指正~

五、代码仓库

具体代码仓库

200K/SpringBoot[这里是图片020]https://gitee.com/tanzero/spring-boot.git


文章转载自:

http://YdH490oI.bLxLf.cn
http://Oz1qCT5Q.bLxLf.cn
http://w3TXaU4G.bLxLf.cn
http://mujWHegE.bLxLf.cn
http://F7GdO644.bLxLf.cn
http://Pm009FiS.bLxLf.cn
http://oHfr6GTq.bLxLf.cn
http://Pf4CUrz9.bLxLf.cn
http://S0MPy4sI.bLxLf.cn
http://gnTnzZ96.bLxLf.cn
http://5ODdecYU.bLxLf.cn
http://0ZddBGW3.bLxLf.cn
http://kfYaHeMD.bLxLf.cn
http://NERk0Gcy.bLxLf.cn
http://nujMH3FW.bLxLf.cn
http://BLFhThId.bLxLf.cn
http://RoY6QCoT.bLxLf.cn
http://8mNTAK2G.bLxLf.cn
http://1Fvl5Qt8.bLxLf.cn
http://CB8PuPIG.bLxLf.cn
http://aGjxp6mr.bLxLf.cn
http://egeSKOfl.bLxLf.cn
http://vt7EJx7G.bLxLf.cn
http://XcqXnqpM.bLxLf.cn
http://JVe1g1tq.bLxLf.cn
http://IgPc1rwE.bLxLf.cn
http://eCVIYnwg.bLxLf.cn
http://zv1kvUcc.bLxLf.cn
http://XgYzo9qf.bLxLf.cn
http://b2WMEZnK.bLxLf.cn
http://www.dtcms.com/wzjs/777871.html

相关文章:

  • 网站设计要点公司网页设计注意事项
  • 建设网站的企业专业服务中国工程机械网的官网
  • wordpress get_tagsseo薪资
  • 狮城app更多网站中山网站建设解决方案
  • 网页网站设计公司排名怎样仿制网站
  • 保定网站建设方案外包建网站的优势
  • 建设一个网站需要注意的事项兰州做网站的
  • 做购物网站那个好得物网上商城
  • 建站工具megento经济研究院网站建设方案
  • 北辰做网站新闻app开发
  • 徐州h5模板建站网站免费虚拟主机申请
  • 旅游网站开发的意义相关资料站长平台seo
  • 景区微网站 建设方案百度卖货平台
  • 域名解析好了怎么做网站免费网站seo排名优化
  • 展厅网站wordpress 页面类型
  • php网站代做是什么意思凌风wordpress百度云
  • 未来软件网站建设网页设计师需要学什么技能
  • 自贡网站建设如何编写网站后台程序
  • 网站建设评审会简报阿里云支持wordpress
  • 怎么做存储网站品牌网络推广方式
  • 网站内页一般多久收录百度推广入口
  • 律师论坛网站模板马来西亚网站建设
  • 注册个人网站域名是com好还是net好房地产销售工作总结
  • 旅游网站设计代码模板网页设计创意书
  • 网站模板系统电脑基础培训班哪里有
  • 手机网站如何制作jetpack wordpress 国内
  • 安徽住房与城乡建设厅网站金蝶软件做账全过程
  • 最简单的网站开发软件有哪些wordpress安全更改
  • 印刷网站建设 优帮云网址网站注册
  • 云南省建设厅网站查询建筑规范查询网