nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
微服务于微服务架构微服务强调服务的大小,他关注某一个点,一个模块只做一种事情微服务架构通常而言,他提倡将单一的程序划分为一组小的服务,每个服务运行在独立的进程中,采用轻量级的通信机制 doubbo是rpc,springcloud是restful
阅读全文
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
启动配置原理几个重要的事件回调机制
ApplicationContextInitializer
SpringApplicationRunListener
ApplicationRunner
CommandLineRunner
启动流程1return new SpringApplication(primarySources).run(args);
创建SpringApplication对象
运行run方法
创建对象现在左边的参数是null
123456789101112public SpringApplication(Class<?>... primarySources) { this(null, primarySources);}public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) { this.resourceLoader = resourceLoader; Assert.notNull(primarySources, "PrimarySources must not be null"); this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources)); this.webApplicationType = WebApplicationType.deduceFromClasspath(); setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class)); setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class)); this.mainApplicationClass = deduceMainApplicationClass();}
阅读全文
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
创建项目选择MySQL+JDBC+Web
链接数据库123456spring: datasource: username: root password: 123456 url: jdbc:mysql://localhost:3306/jdbc driver-class-name: com.mysql.jdbc.Driver
阅读全文
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
整合
创建数据库
导入依赖
建立基本结构和配置框架
编写MyBatis.xml
编写Spring-dao.xml
编写Spring-service.xml
编写web.xml
编写Spring-mvc.xml
编写applicationContext.xml
阅读全文
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
MyBatis是一个对JDBC的封装,是一个数据持久化框架
优点减少代码量,降低维护成本,讲SQL写到XML中,降低耦合度,支持动态SQL语句,支持标签映射,
缺点SQL编写工作量大,SQL语句依赖数据库,导致移植性较差
阅读全文
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
注解配置Controller这里的19行是spring中的注解扫描,21行是不去处理静态资源,23行是配置处理器的适配器
12345678910111213141516171819202122232425262728293031<?xml version="1.0" encoding="utf-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <context:component-scan base-package="com.wsx.controller"/> <!-- 不处理静态资源--> <mvc:default-servlet-handler/> <!-- 配置处理器和适配器--> <mvc:annotation-driven/> <!-- 解析器--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean></beans>
阅读全文