千峰商城-springboot项目实战01-创建与配置

发布时间:2022-06-23 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了千峰商城-springboot项目实战01-创建与配置脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

项目环境:

jdk1.8

千峰商城-springboot项目实战01-创建与配置

 

 idea 2020.03

千峰商城-springboot项目实战01-创建与配置

maven 3.8.4

千峰商城-springboot项目实战01-创建与配置

 

mybatis 3.5.9

 

千峰商城-springboot项目实战01-创建与配置

 

spring 4.3.6

 

千峰商城-springboot项目实战01-创建与配置

 

tomcat 9.0.50

 

千峰商城-springboot项目实战01-创建与配置

 

 mySQL 5.7

千峰商城-springboot项目实战01-创建与配置

 

 

 

1.创建项目

千峰商城-springboot项目实战01-创建与配置

 

 

千峰商城-springboot项目实战01-创建与配置

 

 选择依赖:

千峰商城-springboot项目实战01-创建与配置

 

 

千峰商城-springboot项目实战01-创建与配置

 

 

千峰商城-springboot项目实战01-创建与配置

 

创建项目成功。

千峰商城-springboot项目实战01-创建与配置

 

 删除多余文件

千峰商城-springboot项目实战01-创建与配置

 

 springboot项目基本结构

千峰商城-springboot项目实战01-创建与配置

 

 2.在springboot主配置文件中配置数据源及路径

 application.properties

#配置数据源
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf-8&severTimezone=UTC
spring.activemq.user=root
spring.datasource.password=123456

#映射文件路径
mybatis.mapper-locations=classpath:mappers/*Mapper.xml

#实体类包名
mybatis.type-aliases-package=com.qfedu.springboot.demo.entity

千峰商城-springboot项目实战01-创建与配置

 

 3.引入dao包路径

千峰商城-springboot项目实战01-创建与配置

 

 在demo文件夹中创建dao包,添加一个接口类UserDAO。

在(springboot启动类)主程序SPringbootDemo1Application.java中添加注解MapperScan,指定dao接口的包名。

千峰商城-springboot项目实战01-创建与配置

 

 

package com.qfedu.springboot.demo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("com.qfedu.springboot.demo.dao")
public class SpringbootDemo1Application {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootDemo1Application.class, args);
    }

}

 

 

 

 

脚本宝典总结

以上是脚本宝典为你收集整理的千峰商城-springboot项目实战01-创建与配置全部内容,希望文章能够帮你解决千峰商城-springboot项目实战01-创建与配置所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: