Vue写项目后台SpringBoot 01

打开idea,配置好maven
新建一个SpringBoot项目
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
如果没在这选择依赖,在pom.xml中加也是一样的。

resources目录下的application.properties配置文件,数据库之类的

server.port=8888
#tomcat 端口号
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#数据库版本包
spring.datasource.username=root
#数据库名
spring.datasource.password=123456
#数据库密码
spring.datasource.url=jdbc:mysql://localhost:3306/tp_music?serverTimezone=Asia/Shanghai
#数据库服务器地址
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
#数据库连接池阿里巴巴德鲁伊

数据看表参照
https://blog.csdn.net/aaaaaaddddsssss/article/details/113479652
文后的链接,在项目里有。
在这里插入图片描述
https://mvnrepository.com/artifact/mysql/mysql-connector-java
maven网址
在这里插入图片描述

运行
在这里插入图片描述
在这里插入图片描述
pom.xml

       <dependencies>
        <!--mybatis包-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.4</version>
        </dependency>
        <!--springboot包 包含了spring+springmvc(servlet)-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--热部署包-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <!--mysql包-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.47</version>
        </dependency>
        <!--阿里巴巴 德鲁伊数据库连接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.28</version>
        </dependency>
        <!--springboot jdbc包,mybatis会自动添加这个包,这个包可以不加-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <!--阿帕奇通用包-->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <!--vue 数据传输json 阿里巴巴fastjson-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <!--springBoot测试包-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!--使热部署生效-->
                <configuration>
                    <executable>true</executable>
                    <fork>true</fork>
                </configuration>
            </plugin>
        </plugins>
    </build>

pom.xml依赖
在idea上配置boot热部署
Ctrl+Shift+A 输入registr 勾选compiler.automake.allow.when.app.running
改完代码之后Ctrl+F9就可以了
新增方法就不行,如果你在方法内部新增了什么内容就可以

使用WebMvcConfigurerAdapter类中的跨域解决方法解决跨域
在这里插入图片描述
在这里插入图片描述
在idea目录新建config包
在config包下新建WebMvcConfgi类继承WebMvcConfigurerAdapter重写跨域解决方法

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 解决跨域问题
 */
@Configuration
//使用此注解项目启动会自动加载此类
public class WebMvcConfig extends WebMvcConfigurerAdapter {
   
    @Override
    public void addCorsMappings(CorsRegistry registry) {
   
       registry.addMapping("/")  // 所有目录可以使用跨域访问  所有
               .allowedOrigins("*")  // 允许哪些网站可以使用跨域访问  所有
             .allowedMethods("*")   // 允许哪些方法可以允许使用跨域访问 所有
        .allowCredentials(true); // 访问的时候需要验证 是的
    }
}

在这里插入图片描述
按目录建好文件或者包
在这里插入图片描述
在domain层就是实体类,根据数据库建好实体类

数据库文件

/*
SQLyog Ultimate v12.09 (64 bit)
MySQL - 5.5.57 : Database - tp_music
*********************************************************************
*/


/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`tp_music` /*!40100 DEFAULT CHARACTER SET utf8 */;

USE `tp_music`;

/*Table structure for table `admin` */

DROP TABLE IF EXISTS `admin`;

CREATE TABLE `admin` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `password` varchar(45) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

/*Data for the table `admin` */

insert  into `admin`(`id`,`name`,`password`) values (1,'admin','123'),(2,'admin1','565');

/*Table structure for table `collect` */

DROP TABLE IF EXISTS `collect`;

CREATE TABLE `collect` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `type` tinyint(4) NOT NULL,
  `song_id` int(10) unsigned DEFAULT NULL,
  `song_list_id` int(10) unsigned DEFAULT NULL,
  `create_time` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=utf8;

/*Data for the table `collect` */

insert  into `collect`(`id`,`user_id`,`type`,`song_id`,`song_list_id`,`create_time`) values (2,1,0,21,NULL,'2019-01-07 03:17:42'),(3,94,0,22,NULL,'2019-01-07 16:38:23'),(4,94,0,23,NULL,'2019-01-07 16:41:44'),(6,94,0,21,NULL,'2019-01-07 16:43:45'),(10,94,0,3,NULL,'2019-01-07 16:58:59'),(16,94,0,24,NULL,'2019-01-07 17:34:07'),(21,5,0,24,NULL,'2019-01-08 15:18:33'),(24,5,0,8,NULL,'2019-01-08 16:07:57'),(37,1,0,9,NULL,'2019-04-24 18:10:51'),(41,1,0,16,NULL,'2019-04-24 18:14:31'),(42,1,0,17,NULL,'2019-04-24 18:14:35'),(43,5,0,7,NULL,'2019-04-26 01:06:20'),(45,26,0,44,NULL,'2020-03-21 22:26:37'),(46,26,0,36,NULL,'2020-03-21 22:28:24'),(47,26,0,69,NULL,'2020-03-22 01:56:54'),(48,26,0,45,NULL,'2020-03-22 02:08:36'),(49,26,0,21,NULL,'2020-03-22 02:08:41'),(50,26,0,100,NULL,'2020-03-22 03:41:14'),(51,1,0,22,NULL,'2020-04-05 20:07:09'),(52,12,0,99,NULL,'2020-04-05 21:19:06');

/*Table structure for table `comment` */

DROP TABLE IF EXISTS `comment`;

CREATE TABLE `comment` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `song_id` int(10) unsigned DEFAULT NULL,
  `song_list_id` int(10) unsigned DEFAULT NULL,
  `content` varchar(255) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `type` tinyint(4) NOT NULL,
  `up` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8;

/*Data for the table `comment` */

insert  into `comment`(`id`,`user_id`,`song_id`,`song_list_id`,`content`,`create_time`,`type`,`up`) values (3,1,0,1,'里面乱乱糟糟\n我们别再闹了\n这个冬天已然很冷了\n我们靠在一起。好吗','2019-01-06 16:12:13',1,1),(5,1,21,NULL,'允儿牵动我的心!!!','2019-01-06 18:12:53',0,0),(9,1,22,NULL,'林允儿这个人,饭她真的很骄傲。韩国人说汉语总会带着地域性极强的泡菜味,可是林允儿真的很用心在把准每一个汉字,从咬字到发音,再加上轻柔干净的嗓音加持,将柔美与舒缓表达到极致,将歌里想诉说的那种感情娓娓道来。','2019-01-06 19:36:01',0,0),(10,1,21,NULL,'像我们之间一段长久未诉的告白,被你这样娓娓道来,你问我爱你有多深,我爱你有几分,我的情不移我的爱不变,月亮代表我的心。','2019-01-06 19:44:37',0,3),(11,1,21,NULL,'当听这首歌曲的时候,看看天上的月亮。美爆了!','2019-01-06 19:45:51',0,0),(12,1,23,NULL,'太尼马好听了!堂堂正正的林歌手!!','2019-01-06 19:48:25',0,0),(13,1,23,NULL,'林允儿啊,真的唱的很标准,很动人,我的同学都没想到是林允儿唱的,呜呜呜,爱死你了林允儿','2019-01-06 19:54:01',0,0),(14,1,22,NULL,'真的好棒,我只听她这个版本的','2019-01-06 19:55:43',0,0),(16,1,5,NULL,'好听啊','2019-01-06 19:56:52',0,0),(17,1,22,NULL,'我的允宝啊,努力演戏想让我们看到一样的你,努力学中文唱给我们听越来越爱你了','2019-01-06 19:58:53',0,0),(18,1,22,NULL,'好听啊','2019-01-06 20:01:46',0,0),(19,1,23,NULL,'好听啊','2019-01-06 20:03:59',0,0),(20,1,21,NULL,'好听啊','2019-01-06 20:04:22',0,0),(23,1,NULL,5,'赞!!','2019-01-08 01:05:27',1,2),(24,5,NULL,1,'超喜欢!','2019-01-08 21:46:29',1,0),(25,5,NULL,5,'大爱我林!','2019-01-08 21:47:45',1,1),(26,5,NULL,2,'nice','2019-01-08 22:11:23',1,1),(27,1,NULL,0,'很有感觉','2019-01-08 22:32:51',1,2),(28,5,26,NULL,'好听','2019-01-08 22:42:07',0,0),(29,5,21,NULL,'nice!','2019-01-08 22:57:08',0,0),(30,5,15,NULL,'好听!','2019-01-08 23:03:43',0,0),(31,1,13,NULL,'rrrr','2019-01-15 16:28:03',0,0),(32,1,19,NULL,'赞','2019-03-07 16:34:12',0,0),(33,1,6,NULL,'赞','2019-03-12 09:06:21',0,0),(34,1,NULL,1,'hao','2019-03-16 21:07:01',1,0),(35,1,NULL,38,'hao','2019-03-24 01:39:06',1,0),(36,1,NULL,0,'妙!','2019-03-24 01:48:56',1,1),(37,1,NULL,80,'好听','2019-03-24 01:51:02',1,0),(38,1,NULL,80,'好听!!!','2019-03-24 01:52:20',1,0),(39,1,NULL,80,'好听','2019-03-24 01:53:06',1,0),(40,1,NULL,80,'good','2019-03-24 01:53:45',1,0),(41,1,NULL,80,'nice','2019-03-24 01:55:04',1,0),(42,1,NULL,80,'nice','2019-03-24 01:57:02',1,0),(43,1,NULL,82,'success','2019-03-24 01:57:40',1,0),(45,1,NULL,1,'啦啦啦(*≧∀≦)ノ','2019-04-25 21:24:43',1,0),(46,1,21,NULL,'111','2019-04-26 00:51:18',0,0),(47,1,NULL,1,'222','2019-04-26 01:01:27',1,0),(48,5,NULL,10,'我喜欢你','2019-04-26 01:03:12',1,0),(49,1,NULL,0,'','2019-05-23 21:35:47',1,0),(50,1,NULL,51,'好听','2019-05-23 21:38:04',1,0),(51,1,NULL,5,'好听','2019-05-23 21:39:55',1,0),(52,1,NULL,5,'好听','2019-05-23 21:40:25',1,0),(53,1,107,NULL,'I love you!!!','2019-06-03 02:16:23',0,0),(54,1,95,NULL,'好听','2020-03-14 16:14:53',0,0),(55,1,28,NULL,'?','2020-03-14 16:19:11',0,0),(56,26,69,NULL,'good!','2020-03-22 02:19:03',0,0),(57,26,10,NULL,'good','2020-03-22 03:40:10',0,3);

/*Table structure for table `consumer` */

DROP TABLE IF EXISTS `consumer`;

CREATE TABLE `consumer` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(255) NOT NULL,
  `password` varchar(100) NOT NULL,
  `sex` tinyint(4) DEFAULT NULL,
  `phone_num` char(15) DEFAULT NULL,
  `email` char(30) DEFAULT NULL,
  `birth` datetime DEFAULT NULL,
  `introduction` varchar(255) DEFAULT NULL,
  `location` varchar(45) DEFAULT NULL,
  `avator` varchar(255) DEFAULT NULL,
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username_UNIQUE` (`username`),
  UNIQUE KEY `phone_num_UNIQUE` (`phone_num`),
  UNIQUE KEY `email_UNIQUE` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8;

/*Data for the table `consumer` */

insert  into `consumer`(`id`,`username`,`password`,`sex`,`phone_num`,`email`,`birth`,`introduction`,`location`,`avator`,`create_time`,`update_time`) values (1,'Yin','123',0,'13776412237','yoona@qq.com','2019-05-24 00:00:00','好好吃饭','山西','/avatorImages/1556202448064L1.jpg','2019-01-04 21:42:24','2020-04-05 03:35:12'),(2,'012','012',0,'13754803255','love@gmail.com','2019-04-24 00:00:00','我就喜欢吃','北京','/img/user.jpg','2019-01-05 15:02:45','2020-03-23 01:24:59'),(5,'789','789',0,'13634377258','666@126.com','2019-01-08 21:15:48','今天很开心啊','山西','/avatorImages/1552354056660L1.jpg','2019-01-07 16:16:42','2019-01-08 21:15:48'),(8,'tawuhen','123',0,'','192673541@qq.com','2019-04-25 18:58:39','你好','北京','/img/user.jpg','2019-04-25 00:28:58','2019-04-25 18:58:39'),(12,'yoona','123',0,'13854173655','1236795@qq.com','2019-04-25 10:56:54','hhh','北京','/avatorImages/1584896565998L1.jpg','2019-04-25 10:56:54','2019-04-25 10:56:54'),(16,'1234321','123',1,'13754803257','123@qq.com','2020-03-08 17:25:45','','','/img/user.jpg','2020-03-08 17:25:45','2020-03-08 17:25:45'),(20,'234321','123',0,'15754801257','12987@qq.com','2020-03-08 23:41:22','','','/img/user.jpg','2020-03-08 23:41:22','2020-03-08 23:41:22'),(21,'yoonaA','123',1,NULL,NULL,'2020-03-25 00:00:00','','','/img/user.jpg','2020-03-21 22:18:33','2020-03-21 22:18:33'),(24,'yoonaAA','123',1,NULL,NULL,'2020-03-04 00:00:00','','','/img/user.jpg','2020-03-21 22:20:27','2020-03-21 22:20:27'),(25,'yoonaAB','123',1,NULL,NULL,'2020-03-02 00:00:00','','','/img/user.jpg','2020-03-21 22:21:50','2020-03-21 22:21:50'),(26,'yoonaAC','123',1,'null','null','2020-03-11 00:00:00','','','/img/user.jpg','2020-03-21 22:23:43','2020-04-05 03:30:34'),(27,'yoonaAD','123',1,NULL,NULL,'2020-03-11 00:00:00','','','/img/user.jpg','2020-03-21 22:24:47','2020-03-21 22:24:47'),(28,'yoona90','123',0,NULL,NULL,'2020-04-28 00:00:00','','','/img/user.jpg','2020-04-02 22:10:34','2020-04-02 22:10:34');

/*Table structure for table `list_song` */

DROP TABLE IF EXISTS `list_song`;

CREATE TABLE `list_song` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `song_id` int(10) unsigned NOT NULL,
  `song_list_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=210 DEFAULT CHARSET=utf8;

/*Data for the table `list_song` */

insert  into `list_song`(`id`,`song_id`,`song_list_id`) values (1,36,1),(3,5,2),(4,7,2),(5,11,2),(6,38,6),(7,39,6),(8,44,1),(9,22,2),(10,22,12),(11,38,5),(12,39,5),(13,38,5),(14,39,5),(15,45,4),(16,45,12),(17,10,13),(18,10,2),(19,28,3),(20,10,3),(21,30,10),(22,31,10),(23,82,6),(24,83,6),(25,84,6),(26,85,6
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值