hibernate mysql 视图查询_Springboot+hibernate简单的增删改查

1、创建好项目之后在

b06bc725c6a5149cd1bc9e81a5785714.png配置端口号(也可以不用配置,默认端口8080)

#server

server.port=8080server.tomcat.uri-encoding=utf-8

2、配置mysql

#MySQL

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.datasource.url=jdbc:mysql://localhost:3306/test?characterEncoding=utf8

spring.datasource.username=*****spring.datasource.password=*****

3、配置jpa以及视图层

#Spring Data JPA

spring.jpa.database=MYSQL

spring.jpa.show-sql=truespring.jpa.hibernate.ddl-auto=update

# Naming strategy

spring.jpa.hibernate.naming-strategy =org.hibernate.cfg.ImprovedNamingStrategy

# stripped before adding them to the entity manager)

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

#视图层控制

spring.mvc.view.prefix=classpath:/templates/spring.mvc.view.suffix=.html

spring.mvc.static-path-pattern=/static/**

4、在pom中加入springboot需要的依赖

org.springframework.boot

spring-boot-starter-web

mysql

mysql-connector-java

5.1.39

org.springframework.boot

spring-boot-starter-thymeleaf

1.4.0.RELEASE

org.springframework.boot

spring-boot-starter-data-jpa

1.5.1.RELEASE

com.alibaba

fastjson

1.2.46

整个包结构

1d87ceccdc697840d4750d459e7b3eec.png

Controller

package com.song.configuration.controller;

import com.alibaba.fastjson.JSONObject;

import com.song.configuration.entity.User;

import com.song.configuration.service.UserService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值