【Java-SpringBoot+Vue+MySql】项目开发综合—经验总结

news2024/9/26 5:17:10

目录

框架:

编程思维:

MVC架构:

前端——组件式开发

开发思路梳理:

后端——

前端——

效果图 

         信息列表:

         修改用户​编辑

         新增用户

删除用户

数据清空

批量上传


框架:

后端:JAVA-SpringBoot2.6、包管理器Maven3.6、JDK1.8

数据:MySQL5.7、可视化工具Navicat

前端:Vue2.x、Element-ui3.x、jqurey、axios

编程思维:

后端——自底向上思想:

数据表——》实体层(pojo/entity):实体类——》映射层(dao/mapper):编写数据库连接接口和mapper.xml(使用Mybatis语句连接数据库)——》业务层(service):Service接口和ServiceImpl实现类——》控制层(Controller):Controller类

MVC架构:

M——模型/数据

V——视图/页面

C——控制/数据页面

前端——组件式开发

重要知识点

VUE的基本语法

(Components)组件式开发

(Router)路由转发

(Axios)网络请求

(VueX)状态管理

 

开发思路梳理:

后端——

创建数据库、数据表

 

后端连接数据库

 进行数据映射

实体类

 

 Mybatis——》数据库映射

 

 Mapper接口(Dao/mapper)

 

 

业务层接口与实现

 接口中定义抽象函数

实现基本上就是调用Dao层方法 

 控制层

 控制类

 

前端——

vue支持组件式开发,每个组件基本上都有三大模块组成:<template/>、<scripts/>、<style/>

基本语法不过多说,重点在于Router(路由配置)和Axios(网络请求)。

路由配置时注意引入组件,

按格式设置子路由。

import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'dashboard' }
    }]
  },

  {
    path: '/user',
    component: Layout,
    redirect: '/user',
    name: 'User',
    meta: { title: 'User', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/user/userlist'),
        meta: { title: 'User', icon: 'table' }
      }
    ]
  },

  {
    path: '/userupload',
    component: Layout,
    redirect: '/userupload',
    name: 'Upload',
    meta: { title: 'Upload', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'userupload',
        name: 'Upload',
        component: () => import('@/views/upload/index'),
        meta: { title: 'Upload', icon: 'table' }
      }
    ]
  },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    meta: { title: 'Example', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: 'Table', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: 'Tree', icon: 'tree' }
      }
    ]
  },

  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: 'Form', icon: 'form' }
      }
    ]
  },

  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: 'Nested',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: 'Menu1' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: 'Menu1-1' }
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/nested/menu1/menu1-2'),
            name: 'Menu1-2',
            meta: { title: 'Menu1-2' },
            children: [
              {
                path: 'menu1-2-1',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                name: 'Menu1-2-1',
                meta: { title: 'Menu1-2-1' }
              },
              {
                path: 'menu1-2-2',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                name: 'Menu1-2-2',
                meta: { title: 'Menu1-2-2' }
              }
            ]
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'Menu1-3',
            meta: { title: 'Menu1-3' }
          }
        ]
      },
      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Menu2',
        meta: { title: 'menu2' }
      }
    ]
  },

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router

网络请求时:

注意:数据绑定、双向绑定、获取一行的数据、网络请求传参……

<template>
  <div>
    <el-table :data="tableData" style="width: 100%" max-height="250">
      <el-table-column prop="id" label="用户ID" width="300"> </el-table-column>
      <el-table-column prop="account" label="用户账号" width="300">
      </el-table-column>
      <el-table-column fixed prop="username" label="用户姓名" width="100">
      </el-table-column>
      <el-table-column prop="password" label="用户密码" width="300">
      </el-table-column>
      <el-table-column fixed prop="address" label="用户住址" width="100">
      </el-table-column>

      <el-table-column fixed="right" label="操作" width="120">
            <template slot-scope="scope">
              <!-- {{scope.row.id}} -->
              <el-button @click.native.prevent="update_(scope.row)" type="text" size="small">
          修改
            </el-button>
              <el-button @click.native.prevent="delete_(scope.row.id)" type="text" size="small">
          删除
        </el-button>
            </template>
      </el-table-column>
    </el-table>
    <el-row style="float: right">
      <el-button
@click.native.prevent="add()"
type="text"
        >新增数据</el-button
      >
      <el-button
@click.native.prevent="removeAll()"
type="text"
        >数据清空</el-button
      >
    </el-row>
    <!--    新增弹窗-->
    <el-dialog
            title="新增用户"
            :visible.sync="dialogVisible_add"
            width="30%">
        <el-form ref="form" :model="user" label-width="80px">
            <el-form-item label="用户账号">
                <el-input v-model="user.account"></el-input>
            </el-form-item>
            <el-form-item label="用户姓名">
                <el-input v-model="user.username"></el-input>
            </el-form-item>
            <el-form-item label="用户密码">
                <el-input v-model="user.password"></el-input>
            </el-form-item>
            <el-form-item label="用户地址">
                <el-input v-model="user.address"></el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible_add = false">取 消</el-button>
            <el-button type="primary" @click="save_add">确 定</el-button>
        </span>
    </el-dialog>
    <!--    修改弹窗-->
    <el-dialog
            title="修改用户"
            :visible.sync="dialogVisible_up"
            width="30%">
        <el-form ref="form" :model="user" label-width="80px">
            <el-form-item label="用户账号">
                <el-input v-model="user.account"></el-input>
            </el-form-item>
            <el-form-item label="用户姓名">
                <el-input v-model="user.username"></el-input>
            </el-form-item>
            <el-form-item label="用户密码">
                <el-input v-model="user.password"></el-input>
            </el-form-item>
            <el-form-item label="用户地址">
                <el-input v-model="user.address"></el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible_up = false">取 消</el-button>
            <el-button type="primary" @click="save_up">确 定</el-button>
        </span>
    </el-dialog>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  data() {
    return {
      tableData: [], // 数据列表
      dialogVisible_add: false, // 新增弹窗控制器
      dialogVisible_up: false, // 新增弹窗控制器
      user: { // 数据封装
        account: '',
        username: '',
        password: '',
        address: ''
      }
    }
  },
  created: function() {
    this.loadTableData()
  },
  methods: {
    loadTableData() {
      axios.get('http://localhost:8088/queryAll').then((response) => {
        this.tableData = response.data
      })
    },
    update_(row) {
      this.dialogVisible_up = true
      this.user = row
    },
    delete_(id) {
      // console.log(this.user)
      const data = JSON.stringify(this.user)
      console.log(data)
      if (confirm('是否删除此数据?')) {
        axios.get('http://localhost:8088/remove?id=' + id).then((response) => {
          this.loadTableData()
          location.reload(0)
        })
      } else {
        location.reload(0)
      }
    },
    add() {
      this.user = {}
      this.dialogVisible_add = true
    },
    save_add() {
      // 新增
      axios.post('http://localhost:8088/add', this.user).then((response) => {
        this.dialogVisible_add = false
        this.loadTableData()
      })
    },
    save_up() {
      axios.post('http://localhost:8088/update', this.user).then((response) => {
        this.dialogVisible_up = false
        this.loadTableData()
      })
    },
    removeAll() {
      if (confirm('是否全部删除?')) {
        axios.get('http://localhost:8088/removeAll').then((response) => {
          console.log('已全部删除')
        })
      }
      location.reload(0)
    }
  }
}
</script>

特殊说明:要想在vue中使用JQuery需要下载安装第三方依赖。

更多参考:【Java-SpringBoot+Vue+MySql】项目开发杂记_代码骑士的博客-CSDN博客

效果图 

1、信息列表:

 2、修改用户

 3、新增用户

4、删除用户

 

5、 数据清空

6、批量上传

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/688765.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

13.RocketMQ之消息的存储与发送

1. 消息存储 1.1 消息存储 分布式队列因为有高可靠性的要求&#xff0c;所以数据要进行持久化存储。 消息生成者发送消息Broker收到消息&#xff0c;将消息进行持久化&#xff0c;在存储中新增一条记录返回ACK给生产者Broker消息给对应的消费者&#xff0c;然后等待消费者返回A…

Keras-4-深度学习用于计算机视觉-猫狗数据集训练卷积网络

0. 说明&#xff1a; 本篇学习记录主要包括&#xff1a;《Python深度学习》的第5章&#xff08;深度学习用于计算机视觉&#xff09;的第2节&#xff08;在小型数据集上从头开始训练一个卷积神经网络&#xff09;内容。 相关知识点&#xff1a; 从头训练卷积网络&#xff1b…

AI 绘画用 Stable Diffusion 图生图局部重绘功能给美女换装(这是我能看的嘛)

昨天带大家一起装好了 Stable Diffusion 的环境&#xff0c;今天就来带大家一起体验一下 Stable Diffusion 的局部重绘功能。 没装好环境的可以看上一篇&#xff1a;AI 绘画基于 Kaggle 10 分钟搭建 Stable Diffusion&#xff08;保姆级教程&#xff09; Stable Diffusion 的…

可重入,可打断,公平锁,条件变量原理解读

目录 可重入原理 可打断原理 不可打断模式 可打断模式 公平锁实现原理 条件变量实现原理 await 流程 signal 流程 可重入原理 什么是可重入&#xff1a;当线程请求一个由其它线程持有的对象锁时&#xff0c;该线程会阻塞&#xff0c;而当线程请求由自己持有的对象锁…

阿里刚换帅,京东忙换将:新时代号角吹响

6月26日早间&#xff0c;京东物流在港交所发布公告称&#xff0c;京东物流CEO余睿因个人身体原因辞任执行董事、首席执行官及授权代表&#xff0c;原京东产发CEO胡伟将担任京东物流CEO。 同时&#xff0c;据《科创板日报》报道&#xff0c;京东集团将新成立创新零售部&#xf…

【论文笔记】Fast Segment Anything

我说个数&#xff1a;一个月5篇基于Fast Segment Anything的改进的论文就会出现哈哈哈哈。 1.介绍 1.1 挑战 SAM架构的主要部分Transformer&#xff08;ViT&#xff09;模型相关的大量计算资源需求&#xff0c;这给其实际部署带来了障碍 1.2 任务解耦 将分段任意任务解耦为…

正确认识:1189194-65-7,DOTA-CH2-Alkynyl (TFA salt),试剂的结构式和CAS

文章关键词&#xff1a;双功能螯合剂&#xff0c;大环配体&#xff0c;标记螯合剂修饰 【产品描述】 DOTA-CH2-Alkynyl (TFA salt)中TFA是一种强酸。它可以质子化任何氨基。盐酸也是这样。在纯化多肽过程中的反相HPLC&#xff0c;有一种技术是阴离子交换。将多肽加载在柱子上&a…

MySql基础教程(三):创建数据表、数据增删改查、删除数据表

MySql基础教程(三)&#xff1a;创建数据表、数据增删改查、删除数据表 1、创建数据表 创建MySQL数据表需要以下信息&#xff1a; 表名表字段名定义每个表字段 1.1 语法 下面是创建MySQL数据表的SQL通用语法&#xff1a; CREATE TABLE table_name (column_name column_typ…

无线蓝牙通信有关(NRF2401模块)的功耗,通道频率等

参考&#xff1a; ISM频段 Industrial Scientific Medical,ISM&#xff08;工业、科学、医疗&#xff09;频段为国际电信联盟&#xff08;ITU&#xff09;《无线电规则》定义的指定无线电频段。 Frequency-Shift Keying 数字调制技术&#xff08;FSK调制&#xff09; 将需要…

又是一年毕业季,准备好踏入职场了吗?

文章目录 一、大学时光二、给毕业生的一些建议三、职场中的经验分享四、程序员未来职业规划 一、大学时光 作为一名程序员&#xff0c;大学时光是我职业生涯中最重要的时期之一。这四年的大学&#xff0c;我不仅学到了计算机科学的理论知识&#xff0c;还积累了丰富的编程经验…

tqdm:python的简单可视化进度

tqdm&#xff1a;python的简单可视化进度 说明 ​ 本篇文章的主要目的是快速上手使用&#xff0c;而不是解析源码。 目录结构 文章目录 tqdm&#xff1a;python的简单可视化进度1. 应用场景2. 库安装3. 方法速览4. 案例5. 总结 1. 应用场景 ​ 进度条应用的场景很多&#xff0…

YOLOv8独家原创改进:独家首发最新原创XIoU_NMS改进点,改进有效可以直接当做自己的原创改进点来写,提升网络模型性能、收敛速度和鲁棒性

💡该教程为属于《芒果书》📚系列,包含大量的原创首发改进方式, 所有文章都是全网首发原创改进内容🚀 💡本篇文章为YOLOv8独家原创改进:独家首发最新原创XIoU_NMS改进点,改进有效可以直接当做自己的原创改进点来写,提升网络模型性能、收敛速度和鲁棒性。 💡对自己…

[RocketMQ] Producer发送消息的总体流程 (七)

单向发送: 把消息发向Broker服务器, 不管Broker是否接收, 只管发, 不管结果。同步发送: 把消息发向Broker服务器, 如果Broker成功接收, 可以得到Broker的响应。异步发送: 把消息发向Broker服务器, 如果Broker成功接收, 可以得到Broker的响应。异步所以发送消息后, 不用等待, 等…

css基础知识十:介绍一下CSS中的Grid网格布局?

一、是什么 Grid 布局即网格布局&#xff0c;是一个二维的布局方式&#xff0c;由纵横相交的两组网格线形成的框架性布局结构&#xff0c;能够同时处理行与列 擅长将一个页面划分为几个主要区域&#xff0c;以及定义这些区域的大小、位置、层次等关系 这与之前讲到的flex一维…

操作系统—内存管理

单片机是没有操作系统的&#xff0c;每次写完代码都是通过一些工具将程序直接烧录进去&#xff0c;这样程序才能跑起来。单片机的CPU是直接操作内存的物理地址。在这种情况下&#xff0c;要想在内存中同时运行两个程序是不可能的&#xff0c;程序会崩溃。那么操作系统为了解决这…

LLM相关的一些调研

Prompt Engine 可以参考该项目&#xff0c;该项目提供关于提示词书写的规则。由openai以及吴恩达完成。 https://github.com/datawhalechina/prompt-engineering-for-developers由于目前chatgpt 无法直接在国内访问&#xff0c;推荐在claude on slack上尝试。关于claude api h…

Leetcode:1035. 不相交的线、53. 最大子数组和(C++)

目录 1035. 不相交的线 题目描述&#xff1a; 实现代码与解析&#xff1a; 动态规划 原理解析&#xff1a; 53. 最大子数组和 题目描述&#xff1a; 实现代码与解析&#xff1a; 动态规划 原理思路&#xff1a; 1035. 不相交的线 题目描述&#xff1a; 在两条独立的水…

移动端永不过时的高薪技术岗位,原来是它……

随着 Android 设备的普及和应用领域的不断扩大&#xff0c;Android Framework 开发需求量将会持续增长&#xff0c;并且会越来越多地向行业、企业级应用和系统优化等方向发展。以下是一些 Android Framework 开发相关的应用场景&#xff1a; 1. 特定垂直领域的智能设备&#x…

Jmeter性能测试

一、jmeter多并发 1.线程设置&#xff1a; 线程数——多少个虚拟用户 ramp_up时间(秒)——时间&#xff0c;设置时间内将线程都跑完 循环次数——勾选永远&#xff0c;就一直跑&#xff0c;直到手动停止&#xff1b;输入数字&#xff0c;就是循环多少次 2.jmeter逻辑分支控制…

关于MySQL性能优化方案,掌握这一篇就够了!

目录 前言 一、设置索引 1、索引的优缺点: 2、给表列创建索引 3、查看索引 4、删除索引&#xff1a; 5、索引原理&#xff1a; 二、分类讨论 三、针对偶尔很慢的情况 1、 数据库在刷新脏页&#xff08;flush&#xff09; 2. 拿不到锁我能怎么办 四、针对一直都这…