Spring学习笔记之基础、IOC、DI(1)
0.0 Spring基本特性
Spring是一个开源框架;是基于Core来架构多层JavaEE系统
1.0 IOC
控制反转:把对象的创建过程交给spring容器来做。
1.1 applicationContext.xml
beans 存放了很多个类
把一个类放入到spring容器中,该类就是bean
一个bean就是描述一个类
id就是标示符
命名规范:类的第一个字母变成小写,其他的字母保持不变
class为类的全名
1.2 别名,模块别名
<alias name="helloWorld" alias="雷">
1.3 对象的创建方式
1.3.1 无参构造函数。(多数使用)
<bean id=“personService" class="com.demo.bean.impl.PersonServiceImpl"/>
/**
* spring容器在默认的情况下使用默认的构造函数创建对象
*/
@Test
public void testCreateObject_Default(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
HelloWorld helloWorld = (HelloWorld)context.getBean("helloWorld");
helloWorld.hello();
}
1.3.2 静态工厂。
<bean id="helloWorld2"
class="come.demo.spring.ioc.createobject.method.HelloWorldFactory"
factory-method="getInstance"></bean>
public class HelloWorldFactory {
public static HelloWorld getInstance(){
return new HelloWorld();
}
}
/**
* 在spring容器 内部,调用了HelloWorldFactory中的getInstance方法
* 而该方法的内容就是创建对象的过程,是由程序员来完成
*/
@Test
public void testCreateObject_StaticFactory(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
HelloWorld helloWorld = (HelloWorld)context.getBean("helloWorld2");
helloWorld.hello();
}
1.3.3 实例工厂。
<bean id="helloWorldFactory" class="come.demo.spring.ioc.createobject.method.HelloWorldFactory2"></bean>
<!--
factory-bean指向了实力工厂的bean
factory-method实例工厂对象的方法
-->
<bean id="helloWorld3" factory-bean="helloWorldFactory" factory-method="getInstance"></bean>
public class HelloWorldFactory2 {
public HelloWorld getInstance(){
return new HelloWorld();
}
}
/**
* 实例工厂
* 1、spring容器创建一个实例工厂bean
* 2、该bean调用了工厂方法getInstance产生对象
*/
@Test
public void testCreateObject_InstanceFactory(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
HelloWorld helloWorld = (HelloWorld)context.getBean("helloWorld3");
helloWorld.hello();
}
1.4 范围
1.4.1 在默认情况下,spring容器产生的对象是单例的
<bean id="helloWorld"
class="come.demo.spring.ioc.scope.HelloWorld"></bean>
public class HelloWorld {
public HelloWorld(){
System.out.println("new instance");
}
public void hello(){
System.out.println("hello world");
}
}
@Test
public void testScope_Default(){
ApplicationContext context
= new ClassPathXmlApplicationContext("applicationContext.xml");
HelloWorld helloWorld = (HelloWorld)context.getBean("helloWorld");
System.out.println(helloWorld);
HelloWorld helloWorld2 = (HelloWorld)context.getBean("helloWorld");
System.out.println(helloWorld2);
}
1.4.2 如果scope为"prototype",则为多实例
<bean id="helloWorld"
class="come.demo.spring.ioc.scope.HelloWorld"
scope="prototype"></bean>
@Test
public void testScope_Prototype(){
ApplicationContext context
= new ClassPathXmlApplicationContext("applicationContext.xml");
HelloWorld helloWorld = (HelloWorld)context.getBean("helloWorld");
HelloWorld helloWorld2 = (HelloWorld)context.getBean("helloWorld");
}
1.4.3 larzyscope
如果scope为"prototype",多例。
那么lazy-init属性将失去作用
@Test
public void testScope_Prototype_Lazy_Default(){
ApplicationContext context
= new ClassPathXmlApplicationContext("applicationContext.xml");
HelloWorld helloWorld = (HelloWorld)context.getBean("helloWorld");
HelloWorld helloWorld2 = (HelloWorld)context.getBean("helloWorld");
System.out.println(helloWorld);
System.out.println(helloWorld2);
}
1.4.4 spring创建对象的时间。
1.0 默认(一般更安全,若果spring配置文件有错误,在启动spring容器时就会报错)
<bean id="helloWorld"
class="come.demo.spring.ioc.scope.HelloWorld"></bean>
1.1 加载spring容器
1.2 spring容器调用默认的构造函数为bean创造对象
1.3 利用context.getBean把对象取出来
2.0 lazy-init=“true" ,在启动spring容器的时候是发现不了错误的
<bean id="helloWorld"
class="come.demo.spring.ioc.scope.HelloWorld"
lazy-init="true"></bean>
2.1 启动spring容器
2.2 执行context.getBean
2.3 spring容器为该bean创建对象
1.5 ioc和destory
1.5.1 applicationContext.xml
<!--
destroy-method 销毁该对象的方法
-->
<bean id="helloWorld"
class="come.demo.spring.ioc.initdestroy.HelloWorld"
init-method="init"
destroy-method="destroy"
scope="prototype"></bean>
1.5.2 HelloWorld
public class HelloWorld {
public HelloWorld(){
System.out.println("new instance");
}
public void init(){
System.out.println("init");
}
public void destroy(){
System.out.println("detroy");
}
public void hello(){
System.out.println("hello world");
}
}
1.5.3 InitDestroyTest.java
public class InitDestroyTest {
/**
* 1、启动spring容器
* 2、创建helloWorld对象
* 3、执行init方法 该方法是由spring容器内部调用
* 4、context.getBean把对象提取出来
* 5、对象调用方法
* 6、当执行close方法的时候,执行该对象的destroy方法 是由spring容器内部调用
*/
@Test
public void testInitDestroy_Scope_Default(){
ApplicationContext context = new
ClassPathXmlApplicationContext("applicationContext.xml");
HelloWorld helloWorld = (HelloWorld)context.getBean("helloWorld");
helloWorld.hello();
ClassPathXmlApplicationContext applicationContext =
(ClassPathXmlApplicationContext)context;
applicationContext.close();
}
/**
* 1、启动spring容器
* 2、context.getBean把对象提取出来
* 3、创建helloWorld对象
* 4、执行init方法 该方法是由spring容器内部调用
* 5、对象调用方法
* 说明:不负责销毁
*/
@Test
public void testInitDestroy_Scope_Prototype(){
ApplicationContext context = new
ClassPathXmlApplicationContext("applicationContext.xml");
HelloWorld helloWorld = (HelloWorld)context.getBean("helloWorld");
helloWorld.hello();
ClassPathXmlApplicationContext applicationContext =
(ClassPathXmlApplicationContext)context;
applicationContext.close();
}
}
2.0 DI(依赖注入)给属性赋值的过程就是依赖注入
2.1 DI setter
2.1.1 applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="person" class="come.demo.spring.di.xml.setter.Person">
<!--
property描述的就是bean中的属性
name属性就是描述属性的名称
value就是值 如果是基本属性(String),就用value赋值
ref 如果是引用类型,用ref赋值
-->
<property name="pid" value="1"></property>
<property name="name" value="王二麻子"></property>
<property name="student" ref="student"></property>
<property name="lists">//装配,给list赋值的过程。
<list>
<value>list1</value>
<value>list2</value>
<!--
list中存放一个student对象
-->
<ref bean="student"/>
</list>
</property>
<property name="objects">
<list>
<value>obj1</value>
<ref bean="student"/>
</list>
</property>
<property name="sets">
<set>
<value>set1</value>
<ref bean="student"/>
</set>
</property>
<property name="map">
<map>
<entry key="m1">
<value>m1</value>
</entry>
<entry key="m2">
<ref bean="student"/>
</entry>
</map>
</property>
<property name="properties">
<props>
<prop key="p1">p1</prop>
<prop key="p2">p2</prop>
</props>
</property>
</bean>
<bean id="student" class="come.demo.spring.di.xml.setter.Student"
scope="prototype"></bean>
</beans>
2.1.2 person.java
public class Person {
private Long pid;
private String name;
private Student student;//引用类型
private List lists;
private Set sets;//集合
private Map map;
private Object[] objects;//数组
private Properties properties;
public Person(){
System.out.println("person");
}
public Long getPid() {
return pid;
}
public void setPid(Long pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
public List getLists() {
return lists;
}
public void setLists(List lists) {
this.lists = lists;
}
public Set getSets() {
return sets;
}
public void setSets(Set sets) {
this.sets = sets;
}
public Map getMap() {
return map;
}
public void setMap(Map map) {
this.map = map;
}
public Object[] getObjects() {
return objects;
}
public void setObjects(Object[] objects) {
this.objects = objects;
}
public Properties getProperties() {
return properties;
}
public void setProperties(Properties properties) {
this.properties = properties;
}
@Override
public String toString() {
return "Person [pid=" + pid + ", name=" + name + ", student=" + student
+ ", lists=" + lists + ", sets=" + sets + ", map=" + map
+ ", objects=" + Arrays.toString(objects) + ", properties="
+ properties + "]";
}
}
student.java
public class Student {
public Student(){
System.out.println("student");
}
public void say(){
System.out.println("student");
}
}
2.1.3
Test.java
public class DIXMLSetterTest {
/**
* 1、启动spring容器
* 2、给person创建对象
* 3、给student创建对象
* 4、调用person的各个属性的setter方法赋值
* 5、context.getBean
* 6、对象调用方法
*/
@Test
public void testDI_XML_Setter_Default(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
Person person = (Person)context.getBean("person");
System.out.println(person.toString());
}
@Test
public void testDI_XML_Setter_Person_Default_Student_Lazyinit_TRUE(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
Person person = (Person)context.getBean("person");
System.out.println(person.toString());
}
/**
* 1、启动spring容器
* 2、创建Student对象
* 3、context.getBean
* 4、创建person对象
* 5、调用setter方法赋值
* 6、对象调用方法
*/
@Test
public void testDI_XML_Setter_Person_Lazyinit_TRUE_Student_Lazyinit_Default(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
Person person = (Person)context.getBean("person");
System.out.println(person.toString());
}
/**
* 1、启动spring容器
* 2、创建Student对象
* 3、context.getBean
* 4、创建person对象
* 5、调用setter方法赋值
* 6、对象调用方法
*/
@Test
public void testDI_XML_Setter_Person_Scope_Prototype_Student_Scope_Default(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
Person person = (Person)context.getBean("person");
System.out.println(person.toString());
}
/**
* 1、启动spring容器
* 2、创建person对象
* 3、创建student对象 student的scope为"prototype",但是创建对象在spring容器启动的时候
* 因为Person中的很多属性都依赖于student,而这些属性的赋值发生在spring容器启动的时候
* 4、调用setter方法赋值
* 5、 context.getBean
* 6、对象调用方法
*/
@Test
public void testDI_XML_Setter_Person_Scope_Default_Student_Scope_Prototype(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
Person person = (Person)context.getBean("person");
System.out.println(person.toString());
}
}
2.2 Di的init、destroy执行顺序
2.2.1 applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="person" class="come.demo.spring.di.xml.setterinitdestroy.Person"
init-method="init">
<!--
property描述的就是bean中的属性
name属性就是描述属性的名称
value就是值 如果是基本属性(String),就用value赋值
ref 如果是引用类型,用ref赋值
-->
<property name="pid" value="1"></property>
<property name="name" value="王二麻子"></property>
<property name="student" ref="student"></property>
<property name="lists">
<list>
<value>list1</value>
<value>list2</value>
<!--
list中存放一个student对象
-->
<ref bean="student"/>
</list>
</property>
<property name="objects">
<list>
<value>obj1</value>
<ref bean="student"/>
</list>
</property>
<property name="sets">
<set>
<value>set1</value>
<ref bean="student"/>
</set>
</property>
<property name="map">
<map>
<entry key="m1">
<value>m1</value>
</entry>
<entry key="m2">
<ref bean="student"/>
</entry>
</map>
</property>
<property name="properties">
<props>
<prop key="p1">p1</prop>
<prop key="p2">p2</prop>
</props>
</property>
</bean>
<bean id="student" class="come.demo.spring.di.xml.setterinitdestroy.Student"></bean>
</beans>
2.2.2 java文件
Person.java
public class Person {
private Long pid;
private String name;
private Student student;
private List lists;
private Set sets;
private Map map;
private Object[] objects;
private Properties properties;
public void init(){
System.out.println("init");
}
public Person(){
System.out.println("person");
}
public Long getPid() {
return pid;
}
public void setPid(Long pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
public List getLists() {
return lists;
}
public void setLists(List lists) {
this.lists = lists;
}
public Set getSets() {
return sets;
}
public void setSets(Set sets) {
this.sets = sets;
}
public Map getMap() {
return map;
}
public void setMap(Map map) {
this.map = map;
}
public Object[] getObjects() {
return objects;
}
public void setObjects(Object[] objects) {
this.objects = objects;
}
public Properties getProperties() {
return properties;
}
public void setProperties(Properties properties) {
this.properties = properties;
}
@Override
public String toString() {
return "Person [pid=" + pid + ", name=" + name + ", student=" + student
+ ", lists=" + lists + ", sets=" + sets + ", map=" + map
+ ", objects=" + Arrays.toString(objects) + ", properties="
+ properties + "]";
}
}
Student.java
public class Student {
public Student(){
System.out.println("student");
}
public void say(){
System.out.println("student");
}
}
2.2.3 TEST
DIXMLSetterInitDetroyTest.java
public class DIXMLSetterInitDetroyTest {
/**
* 1、启动spring容器
* 2、实例化person,student
* 3、调用person的setter方法进行装配
* 4、调用person的init方法
* 5、context.getBean
* 6、person调用方法完成任务
*/
@Test
public void testDI_XML_Setter_InitDestroy(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
Person person = (Person)context.getBean("person");
System.out.println(person.toString());
}
}
2.3 DI的Setter和Constructor(构造器)
2.3.1 applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="person" class="come.demo.spring.di.xml.constructor.Person">
<!--
constructor-arg 代表某一个构造器的参数
index 构造器参数的下标
value
ref
type 类型
-->
<constructor-arg index="0" value="1" type="java.lang.String"></constructor-arg>
<constructor-arg index="1" ref="student"></constructor-arg>
</bean>
<bean id="student" class="come.demo.spring.di.xml.constructor.Student"></bean>
</beans>
2.3.2
Person.java
public class Person {
private Long pid;
private String name;
private Student student;
private List lists;
private Set sets;
private Map map;
private Object[] objects;
private Properties properties;
//构造函数
public Person(Long pid,String name){
this.pid = pid;
this.name = name;
}
public Person(String name,Student student){
this.name = name;
this.student = student;
}
public void init(){
System.out.println("init");
}
@Override
public String toString() {
return "Person [pid=" + pid + ", name=" + name + ", student=" + student
+ ", lists=" + lists + ", sets=" + sets + ", map=" + map
+ ", objects=" + Arrays.toString(objects) + ", properties="
+ properties + "]";
}
}
Student.java
public class Student {
public Student(){
System.out.println("student");
}
public void say(){
System.out.println("student");
}
}
2.3.3 DIXMLSetterConstructorTest.java
public class DIXMLSetterConstructorTest {
@Test
public void testDI_XML_Constructor(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
Person person = (Person)context.getBean("person");
System.out.println(person.toString());
}
}
2.3.4 如果person.java有set方法,则构造器和set均可以用
person.java
public class Person {
private Long pid;
private String name;
private Student student;
public Person(){}
public Person(String name,Student student){
this.name = name;
this.student = student;
}
public Long getPid() {
return pid;
}
public void setPid(Long pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
@Override
public String toString() {
return "Person [pid=" + pid + ", name=" + name + ", student=" + student
+ "]";
}
}
2.4 IOC和DI的整合,完全的面向接口编程。Document实现。
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!--
把documentManager,wordDocument,excelDocument,pdfDocument放入到spring容器中
-->
<bean id="documentManager" class="come.demo.spring.di.xml.iocdi.setter.DocumentManager">
<!--
该属性是一个接口
-->
<property name="document">
<ref bean="excelDocument"/>
</property>
</bean>
<bean id="wordDocument" class="come.demo.spring.di.xml.iocdi.setter.WordDocument">
</bean>
<bean id="excelDocument" class="come.demo.spring.di.xml.iocdi.setter.ExcelDocument">
</bean>
<bean id="pdfDocument" class="come.demo.spring.di.xml.iocdi.setter.PDFDocument">
</bean>
</beans>
Document.java
public interface Document {
public void read();
public void write();
}
DocumentManager.java
public class DocumentManager {
/**
* 接口
*/
private Document document;
public DocumentManager(){}
public Document getDocument() {
return document;
}
public void setDocument(Document document) {
this.document = document;
}
public DocumentManager(Document document){
this.document = document;
}
public void read(){
//接口调用方法
this.document.read();
}
public void write(){
this.document.write();
}
}
ExcelDocument.java
public class ExcelDocument implements Document{
public void read() {
// TODO Auto-generated method stub
System.out.println("excel read");
}
public void write() {
// TODO Auto-generated method stub
System.out.println("excel write");
}
}
PDFDocument.java
public class PDFDocument implements Document{
public void read() {
// TODO Auto-generated method stub
System.out.println("pdf read");
}
public void write() {
// TODO Auto-generated method stub
System.out.println("pdf write");
}
}
WordDocument.java
public class WordDocument implements Document{
public void read() {
// TODO Auto-generated method stub
System.out.println("word read");
}
public void write() {
// TODO Auto-generated method stub
System.out.println("word write");
}
}
DocumentTest.java
public class DocumentTest {
@Test
public void testDocument_NO_Spring(){
/**
* 等号的左边是接口,等号的右边是实现类
*/
Document wordDocument = new WordDocument();
DocumentManager documentManager = new DocumentManager(wordDocument);
documentManager.read();
documentManager.write();
}
/**
* 在客户端做到了完全的面向接口编程,程序员再也不用在客户端关心document是由谁来实现的
*/
@Test
public void testDocument_Spring(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
DocumentManager documentManager = (DocumentManager)context.getBean("documentManager");
documentManager.read();
documentManager.write();
}
}
2.5 IOC和DI整合,MVC实现。完全面向接口编程
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="personDao" class="come.demo.spring.di.xml.iocdi.setter.mvc.PersonDaoImpl"></bean>
<bean id="personService" class="come.demo.spring.di.xml.iocdi.setter.mvc.PersonServiceImpl">
<property name="personDao">
<ref bean="personDao"/>
</property>
</bean>
<bean id="personAction" class="come.demo.spring.di.xml.iocdi.setter.mvc.PersonAction">
<property name="personService">
<ref bean="personService"/>
</property>
</bean>
</beans>
PersonAction.java
public class PersonAction {
private PersonService personService;
public PersonService getPersonService() {
return personService;
}
public void setPersonService(PersonService personService) {
this.personService = personService;
}
public void savePerson(){
this.personService.savePerson();
}
}
PersonDao.java
public interface PersonDao {
public void savePerson();
}
PersonDaoImpl.java
public class PersonDaoImpl implements PersonDao{
public void savePerson() {
// TODO Auto-generated method stub
System.out.println("save person");
}
}
PersonService.java
public interface PersonService {
public void savePerson();
}
PersonServiceImpl.java
public class PersonServiceImpl implements PersonService{
private PersonDao personDao;
public PersonDao getPersonDao() {
return personDao;
}
public void setPersonDao(PersonDao personDao) {
this.personDao = personDao;
}
public void savePerson() {
// TODO Auto-generated method stub
this.personDao.savePerson();
}
}
MVCTest.java
public class MVCTest {
@Test
public void testMVC(){
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
PersonAction personAction = (PersonAction)context.getBean("personAction");
personAction.savePerson();
}
}
Spring学习笔记之基础、IOC、DI(1)的更多相关文章
- Spring学习笔记1——基础知识 (转)
1.在java开发领域,Spring相对于EJB来说是一种轻量级的,非侵入性的Java开发框架,曾经有两本很畅销的书<Expert one-on-one J2EE Design and Deve ...
- Spring学习笔记1——基础知识
1.在java开发领域,Spring相对于EJB来说是一种轻量级的,非侵入性的Java开发框架,曾经有两本很畅销的书<Expert one-on-one J2EE Design and Deve ...
- Spring学习笔记之The IoC container
IoC is also known as dependency injection (DI). 这是一个过程?什么样的过程呢?对象自己定义它的依赖关系,这意味着,那些他们依赖的对象,只能通过构造函数参 ...
- 【spring学习笔记一】Ioc控制反转
(最近有点捞,在大一的时候还通过写博客的方式督促自己学习唉,先培养起习惯,再找个好点的地方重新开始写博客⑧) Spring是JAVA的一个框架. 有个概念叫依赖注入(或者还有个名字叫控制反转). 概念 ...
- spring学习笔记(一) Spring概述
博主Spring学习笔记整理大部分内容来自Spring实战(第四版)这本书. 强烈建议新手购入或者需要电子书的留言. 在学习Spring之前,我们要了解这么几个问题:什么是Spring?Spring ...
- Java架构师之路 Spring学习笔记(一) Spring介绍
前言 这是一篇原创的Spring学习笔记.主要记录我学习Spring4.0的过程.本人有四年的Java Web开发经验,最近在面试中遇到面试官总会问一些简单但我不会的Java问题,让我觉得有必要重新审 ...
- Spring学习笔记之依赖的注解(2)
Spring学习笔记之依赖的注解(2) 1.0 注解,不能单独存在,是Java中的一种类型 1.1 写注解 1.2 注解反射 2.0 spring的注解 spring的 @Controller@Com ...
- Spring学习笔记(一)
Spring学习笔记(一) 这是一个沉淀的过程,大概第一次接触Spring是在去年的这个时候,当初在实训,初次接触Java web,直接学习SSM框架(当是Servlet都没有学),于是,养成了一个很 ...
- MyBatis:学习笔记(1)——基础知识
MyBatis:学习笔记(1)--基础知识 引入MyBatis JDBC编程的问题及解决设想 ☐ 数据库连接使用时创建,不使用时就释放,频繁开启和关闭,造成数据库资源浪费,影响数据库性能. ☐ 使用数 ...
随机推荐
- phpStudy 升级 MySQL版本
1:停止phpStudy ,Mysql 服务;删除Mysql 文件夹 替换为新版本的Mysql 2:复制一份 my-default.ini,改名 my.ini ,打开,在最后面加上: basedir= ...
- 在阿里云的ubuntu服务器上安装xampp时出现unable to realloc unable to realloc 8380000 bytes错误
在阿里云的ubuntu服务器上安装xampp时出现unable to realloc unable to realloc 8380000 bytes错误 解决:增加Swap空间(阿里云缺省没有分配任何 ...
- bit ( 比特 )和 Byte(字节)的关系
一.存储单位的bit 和 Byte1.bit(比特)bit也就是我们不一定听说过的比特,大名鼎鼎的比特币就是以此命名的.它的简写为小写字母 “b” .作为信息技术的最基本存储单元,因为比特实在太小了, ...
- IE下自定义错误页面不显示的原因
如果一个 404 页面的内容小于 512B,IE 会认为该 404 页面不够友好,在 IE 下将不会成功返回该 404 错误页面
- Git 基础教程 之 删除文件
① 手动或命令 rm删除工作区的问价: git checkout -- readme.txt 可恢复 checkout 实际上是用版本库里的替换工作区的版本 ② 删除了工作区文 ...
- 《奋斗吧!菜鸟》 第八次作业:Alpha冲刺 Scrum meeting 3
项目 内容 这个作业属于哪个课程 任课教师链接 作业要求 https://www.cnblogs.com/nwnu-daizh/p/11012922.html 团队名称 奋斗吧!菜鸟 作业学习目标 A ...
- RestTemplate使用详解
1.RestTemplate添加RequestHeader如content-type可通过httpclient设置 List<Header> headers = new ArrayList ...
- mysql 易错误理解
MySQL作为数据库的一大主力军,到处存在于我们各种系统中,相信大家都不陌生!但是,你知道你能用不代表你知道细节,那我们就来盘点盘点其中一些我们平时不太注意的地方,一来为了有趣,二来为了不让自己踩坑. ...
- MySQL备份 博客---MYSQLDBA 黄杉
http://blog.csdn.net/mchdba/article/category/1598781
- Go在Ubuntu 14.04 64位上的安装过程
1. 从 https://golang.org/dl/ 或 https://studygolang.com/dl 下载最新的发布版本go1.10即go1.10.linux-amd64.tar.gz ...