Spring Boot2 核心功能

Spring Boot2 核心功能

1、文件类型

1、1 properties

yml

控制台输出

单引号会将\n作为字符串输出

双引号会换行输出

单引号会转义,双引号不会转义

person:
  userName: "zhangsan \n 李四"
  boss: true
  birth: 2019/12/09
  age: 21
#  interests: [篮球,足球]
  interests:
    - 篮球
    - 足球
  animal: [阿猫,阿狗]
#  score:
#    english: 80
#    math: 90
  score: {english:80,math:90}
  salarys:
    - 99999.8
    - 99999.9
  pet:
    name: 阿狗
    weight: 99.99

  allPets:
    sick:
      - {name: 阿狗,weight: 99.99}
      - name: 阿猫
        weight: 88.88
      - name: 啊虫
        weight: 11.11
    health:
      - {name: 阿花,weight: 199.99}
      - {name: 阿明,weight: 199.98}

//在templates目录下的所有页面,只能通过controller来跳转

直接导入场景,导入包会报错

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

Thymeleaf语法

$@

:国际化

$:文本

@:地址

定义组件

<nav class="col-md-2 d-none d-md-block bg-light sidebar" th:fragment="sidebar">

插入组件

页面路径+哪个组件

<div th:insert="~{dashboard::sidebar}"></div>
<div class="form-group">
							<label>department</label>
							<select class="form-control" name="department.id">
								<option th:each="department:${departments}" 						th:text="${department.getDepartmentName()}" 						   					th:value="${department.getId()}">1</option>

							</select>
						</div>

自定义Favicon

网页的ico

​ ctrl+shift+r:清除缓存

2022/3/28

  • JDBC
  • Mybatis
  • Druid
  • Shiro:安全
  • Spring Security:安全
  • 异步任务 :(邮件发送,定时任务)
  • Swagger:前后端交接文档技术
  • Dubbo+Zookeeper(难点)

Data

对于数据访问,无论是关系型或者非关系型数据库

Spring Boot都是采用Spring Data进行统一管理

整合MyBatis

@Mapper

@Mapper是mybatis的注解,标注在dao层接口上,可以通过动态代理生成接口的实例bean,启动类不需要添加@MapperScan包扫描

@Repository是spring的注解,也标注在dao层接口上,启动类需要加@MapperScan包扫描,生成对应的bean,加了@MapperScan就相当于给包中的接口都加上了@Mapper,同时@Repository还有消除“注入”的错误提示的作用

有错误提示的就是没加@Repository,这是因为spring的自动扫描,而@Mapper不是spring的注解,所以有无法注入的提示。但是这个影响不大,有@Mapper或@MapperScan就可以生成bean。

以前的时候是在mapper层下面有个impl要实现接口方法

如:

public List<User> findAll() throws IOException {
        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        List<User> userList = sqlSession.selectList("userMapper.findAll");

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值