Springboot整合ssm项目(显示login)05
快速创建springboot项目,勾选web,jdbc,mybatis,Thymeleaf,mysql
 # 应用名称
 spring.application.name=springboot-crm
 # 应用服务 WEB 访问端口
 server.port=8080
 #下面这些内容是为了让MyBatis映射
 #指定Mybatis的Mapper文件
 mybatis.mapper-locations=classpath:mappers/*xml
 #指定Mybatis的实体目录
 mybatis.type-aliases-package=com.galaxy.crm.bean
 # 数据库驱动:
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 # 数据源名称
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
 # 数据库连接地址
 spring.datasource.url=jdbc:mysql://localhost:3306/crm?serverTimezone=Asia/Shanghai
 # 数据库用户名&密码:
 spring.datasource.username=root
 spring.datasource.password=00000
 # THYMELEAF (ThymeleafAutoConfiguration)
 # 开启模板缓存(默认值: true )
 spring.thymeleaf.cache=true
 # 检查模板是否存在,然后再呈现
 spring.thymeleaf.check-template=true
 # 检查模板位置是否正确(默认值 :true )
 spring.thymeleaf.check-template-location=true
 #Content-Type 的值(默认值: text/html )
 spring.thymeleaf.content-type=text/html
 # 开启 MVC Thymeleaf 视图解析(默认值: true )
 spring.thymeleaf.enabled=false
你配置的一定要跟自己项目的路径对的上
接下来程序入口扫mapper
 
都准备好了结果发现少了几个<dependency>
 <!--缺commonlong3-->
 <dependency>
     <groupId>org.apache.commons</groupId>
     <artifactId>commons-lang3</artifactId>
     <version>3.11</version>
 </dependency>
 <!--缺pagehelper-->
 <dependency>
     <groupId>com.github.pagehelper</groupId>
     <artifactId>pagehelper</artifactId>
     <version>5.1.9</version>
 </dependency>
 <!--缺fastjson-->
 <dependency>
     <groupId>com.alibaba</groupId>
     <artifactId>fastjson</artifactId>
     <version>1.2.46</version>
 </dependency>
 <!--缺druid数据源-->
 <dependency>
     <groupId>com.alibaba</groupId>
     <artifactId>druid</artifactId>
     <version>1.1.20</version>
 </dependency>
然后可以用postman测试下自己之前写的接口,看看数据能不能正常访问

可以的话接着写
搞好之后导入静态资源


注意:application.properties里的。。要是true
 # 开启 MVC Thymeleaf 视图解析(默认值: true )
 spring.thymeleaf.enabled=true
1. 新建login.html

之前jsp的

接着写一个欢迎页配置,@SpringBootConfiguration要加,证明它是一个配置类
 package com.galaxy.crm.config;
 
 import org.springframework.boot.SpringBootConfiguration;
 import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 
 
这俩是一样的

写完欢迎页前台效果就出来了:

2.我们要借助Thymeleaf对login.html进行改动

需要注意的改动:

msg爆红不用管他,接下来看前台效果:

login页面显示成功:
下面说一下单体应用与分布式的区别
单体应用

分步式:

扩展:分布式与集群的区别
- 
分布式是将不同的业务分散到不同的服务器上,集群是同一个业务由多台服务器一起完成
 - 
分布式是软件层面,集群是硬件层面
 
何时需要使用分布式?
- 
场景:一个饭店请一个厨师负责配菜和喇菜,一天最多只能喇300份菜。当饭店生意越来越火,一天超过300份菜,怎么办呢?
 - 
应用:
一个服务器也有请求上限,当一个服务器处理不过来的时候,就再加一个服务器分担工作任务。 - 
这就是分布式,也是需要分布式的原因。
 
架构的不同风格
- 
任何一个体系(产品平台、商业模式等)如果想要发展壮大,途径只有两个模式:
①容器模式:从外部提供越来越多的资源和能力,注入到体系的内部,不断的从内扩自己。单体架构的系统类似这种模式。 ② 生态模式:以自己的核心能力为内核,持续的在外部吸引合作者,形成一个可以不断成长的生态体系。分布式架构越来越像这种模式。
 
对于单体架构,我们根据设计期和开发实现期的不同模式和划分结构,可以分为以下几个模式

对于分布式架构,我们根据设计期的架构思想和运行期的不同结构,可以分为:

也有人把如上的各个架构风格总结为4个大的架构发展阶段
                    
                
                
            
        
浙公网安备 33010602011771号