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

服务器放网站吗高校保卫处网站建设工作

服务器放网站吗,高校保卫处网站建设工作,广州网站建设商,怎么自己建立网站最近有个需求&#xff0c;是手机软件离线使用&#xff0c; 用的springboot mybatis-plus mysql&#xff0c;无法实现&#xff0c;于是考虑使用内嵌式轻量级的数据库SQLlite 引入依赖 <dependency><groupId>org.xerial</groupId><artifactId>sqlite-…

最近有个需求,是手机软件离线使用,
用的springboot + mybatis-plus + mysql,无法实现,于是考虑使用内嵌式轻量级的数据库SQLlite

  1. 引入依赖
		<dependency><groupId>org.xerial</groupId><artifactId>sqlite-jdbc</artifactId><version>3.36.0.3</version></dependency>
  1. 修改配置文件
server:port: 9090
spring:datasource:url: jdbc:sqlite:sqlite.dbdriver-class-name: org.sqlite.JDBC
mybatis-plus:mapper-locations: classpath:mapper/*.xmlconfiguration:log-impl: org.apache.ibatis.logging.stdout.StdOutImplglobal-config:db-config:id-type: autotype-aliases-package: com.example.sqlite.entity

此处的url折磨了一晚上,网上各种百度加resource目录下什么的,最后直接这样,启动后会在根目录下自动生成一个db文件。
在这里插入图片描述

  1. 铺底表结构及数据
    预先 生成表结构以及铺地数据,百度了很久并不能通过预先放好sql,然后启动时候动态执行生成。
    最后只能自己在本系统中手动创建好,以及执行好sql,项目打包之后该数据库及铺底数据会内嵌其中

1). 建表语句

DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`
(`id`          INTEGER NOT NULL,`username`    TEXT,`password`    TEXT,PRIMARY KEY (`id`)
)

sqllite的数据类型和mysql不同,但同时也包容(不确定)
简单来说
整数用 INTEGER
字符串用 TEXT
浮点数 REAL

具体可参考该链接: SQLLite基本数据类型

2). 铺地数据

INSERT INTO `user` VALUES (1, '范大', '11111');

将这两个sql放在项目里的文件夹
在这里插入图片描述

3). 添加Sqllite
在这里插入图片描述
在这里插入图片描述
建议方框内的值直接填写生成的db名即可,同时别忘记点击一个test Connection测试一下。

在这里插入图片描述
ok,生成了db。

4). 执行sql
双击该数据库,
在这里插入图片描述
选择之前的sql执行,可以看日志
在这里插入图片描述

两个sql都run一下

在这里插入图片描述

OK, 我这边都成功了

  1. 简单写个demo
    Controller
package com.example.sqlite.controller;import com.example.sqlite.entity.User;
import com.example.sqlite.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {private final UserService userService;@GetMapping("/get/{id}")public User findOne(@PathVariable Integer id) {return userService.getById(id);}@GetMapping("/save/{id}")public void save(@PathVariable Integer id) {User user = new User();user.setId(id);user.setUsername(id+":哈哈哈哈");userService.save(user);}}

service

package com.example.sqlite.service;import com.baomidou.mybatisplus.extension.service.IService;
import com.example.sqlite.entity.User;public interface UserService extends IService<User> {
}

serviceImpl

package com.example.sqlite.service;import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.sqlite.entity.User;
import com.example.sqlite.mapper.UserMapper;
import org.springframework.stereotype.Service;@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService{
}

Mapper

package com.example.sqlite.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.sqlite.entity.User;public interface UserMapper extends BaseMapper<User> {
}

Entity

package com.example.sqlite.entity;import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;@Data
@TableName("user")
public class User {@TableId(value = "id", type = IdType.AUTO)private Integer id;private String username;private String password;}

UserMapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.sqlite.mapper.UserMapper"></mapper>

MybatisPlusConfig

package com.example.sqlite.config;import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;//注入配置springboot
@Configuration
@MapperScan("com.example.sqlite.mapper")
public class MybatisPlusConfig {@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor(){MybatisPlusInterceptor interceptor=new MybatisPlusInterceptor();interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.SQLITE));return interceptor;}
}

启动后,访问成功。
在这里插入图片描述
打个包,java -jar启动
仍然访问成功。

http://www.yayakq.cn/news/751688/

相关文章:

  • 贵阳做网站公司吗网页链接的视频怎么下载
  • 艺美网站建设做书店网站版头
  • 重庆市建设工程施工安全管理总站自己做片头的网站
  • 30几岁的人想学做网站网站内容更新教程
  • 宝安网站制作公司wordpress做幻灯片
  • 临沂seo网站管理容桂网站制作动态
  • 怎么提高网站访问速度泉州网站建设公司首选公司哪家好
  • 郑州 (网站建设现在出入山西最新规定
  • 加强网站的建设工作网站如何做品牌营销
  • 虚拟机中建设iis网站做网站用什么软件方便
  • 域名买了之后如何建设网站郑州制作网站软件
  • 做尽调需要用到的网站具体的网站建设
  • 中山免费建网站vue做社区网站
  • 校园社交网站开发宝安区网站建设培训
  • 建设部网站投标保证金wordpress文章字体修改为宋体
  • 企业电子商务网站有哪些功能苏州网站设计选哪家
  • 网站备案个人好还是企业好wordpress 加斜杠
  • 南沙区交通和建设局网站网站建设应考虑哪些方面的问题
  • 网站建设gzdlzgg网站建设维护成本
  • 网站制作北京山东建站商城
  • 网站建设企业类型是什么h5网站还有哪些
  • 企业网站的设计招标网站建设申请报告
  • 信誉好的南昌网站建设贵州住房和建设厅网站
  • 网站建设与管理专业的行业发展运动类网站
  • 郑州大学现代远程教育《网页设计与网站建设》课程考核要求如何制作网站平台
  • 建设部网站查询公司推广方式是什么意思
  • 东莞网站建设市场seo 优化案例
  • 安居客网站怎么做做网站要开发嘛
  • 湘潭网站建设方案费用网站图片相册代码
  • 建设部网站 测绘规章网站开发逻辑