Spring start

Time: 2024-04-10 16:32:26
Author: Jackasher

Spring start

其实我蛮喜欢spring这个名字,我发现计算机领域用这种干净清爽的名字会给人很舒服的感觉

这么多技术,我发现每一个框架都有一个核心类,

  • Mybatis with sqlsession
  • AJAX with XMLHttpRequest
  • Spring core class is ApplicationContext, this is really like Servlet in JSP of applicationContext, this is a big range, and to be care, it’s a API, ClassPathXMLApplicationContext implments it, really a long name ah!

配置文件的格式

1
2
3
4
5
6
7
8
9
10
<?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.xsd">


<bean id="jack" class="org.example.bean.User"></bean>


</beans>

使用spring

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package org.example;

import org.springframework.context.support.ClassPathXmlApplicationContext;

// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args) {

ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("spring.xml");
Object jack = classPathXmlApplicationContext.getBean("jack");
System.out.println(jack);
}
}

Spring start
http://example.com/2024/04/10/Spring start/
作者
Jack Asher
发布于
2024年4月10日
许可协议