Spring学习总结:IOC基础(1),多线程面试题java

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip1024b (备注Java)
img

正文

  • 音乐

  • @author: kevin

  • @Date: 2018/12/8

*/

public class Music {

public Music() {

System.out.println(“播放周杰伦的《七里香》”);

}

}

resources文件夹下新建music.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.xsd”>

测试类

package com.kevin.spring.demo1.test;

import com.kevin.spring.demo1.entity.Music;

import org.springframework.context.ApplicationContext;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**

  • @author: kevin

  • @Date: 2018/12/8

*/

public class Test {

public static void main(String[] args) {

ApplicationContext ctx = new ClassPathXmlApplicationContext(“music.xml”);

Music jay = ctx.getBean(“jay”, Music.class);

}

}

运行结果

信息: Loading XML bean definitions from class path resource [music.xml]

播放周杰伦的《七里香》

使用有参构造方法创建对象

Person

package com.kevin.spring.demo2.entity;

/**

  • 人类

*/

public abstract class Person {

public String name;

}

Student

package com.kevin.spring.demo2.entity;

/**

  • 学生

*/

public class Student extends Person{

/**

  • 身高

*/

public int height;

/**

  • 有参构造函数

  • @param name

  • @param height

*/

public Student(String name,int height) {

this.name = name;

this.height = height;

}

@Override

public String toString() {

return “Student{” +

“height=” + height +

“, name='” + name + ‘’’ +

‘}’;

}

}

student.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.xsd”>

测试类

package com.kevin.spring.demo2.test;

import com.kevin.spring.demo2.entity.Person;

import com.kevin.spring.demo2.entity.Student;

import org.springframework.context.ApplicationContext;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {

public static void main(String[] args) {

ApplicationContext ctx = new ClassPathXmlApplicationContext(“student.xml”);

Person kevin = ctx.getBean(“kevin”, Student.class);

Person maomao = ctx.getBean(“maomao”, Student.class);

System.out.println(maomao);

System.out.println(kevin);

}

}

输出

信息: Loading XML bean definitions from class path resource [student.xml]

Student{height=100, name=‘maomao’}

Student{height=170, name=‘kevin’}

通过属性赋值

Animal

package com.kevin.spring.demo3.entity;

/**

  • 动物

*/

public class Animal {

/**

  • 动物名称

*/

private String name;

public Animal() {

}

public Animal(String name) {

this.name = name;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

@Override

public String toString() {

return “Animal{” +

“name='” + name + ‘’’ +

‘}’;

}

}

animal.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”

xmlns:p=“http://www.springframework.org/schema/p”

xsi:schemaLocation=“http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd”>

测试

package com.kevin.spring.demo3.test;

import com.kevin.spring.demo3.entity.Animal;

import org.springframework.context.ApplicationContext;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**

  • 测试类

*/

public class Test {

public static void main(String[] args) {

ApplicationContext ctx = new ClassPathXmlApplicationContext(“animal.xml”);

Animal dog = ctx.getBean(“dog”,Animal.class);

Animal cat = ctx.getBean(“cat”,Animal.class);

System.out.println(cat);

System.out.println(dog);

}

}

输出结果

信息: Loading XML bean definitions from class path resource [animal.xml]

Animal{name=‘cat’}

Animal{name=‘dog’}

对象引用

Tyre

package com.kevin.spring.demo4.entity;

/**

  • 轮胎

  • @author: kevin

  • @Date: 2018/12/8

*/

public class Tyre {

private String name;

public Tyre(String name) {

this.name = name;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

@Override

public String toString() {

return “Tyre{” +

“name='” + name + ‘’’ +

‘}’;

}

}

Car

package com.kevin.spring.demo4.entity;

/**

*/

public class Car {

private String name;

private Tyre tyre;

public Car(String name, Tyre tyre) {

this.name = name;

this.tyre = tyre;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public Tyre getTyre() {

return tyre;

}

public void setTyre(Tyre tyre) {

this.tyre = tyre;

}

@Override

public String toString() {

return “Car{” +

“name='” + name + ‘’’ +

“, tyre=” + tyre +

‘}’;

}

}

测试

package com.kevin.spring.demo4.test;

import com.kevin.spring.demo4.entity.Car;

import org.springframework.context.ApplicationContext;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {

public static void main(String[] args) {

ApplicationContext ctx = new ClassPathXmlApplicationContext(“car.xml”);

Car bike = ctx.getBean(“bike”, Car.class);

System.out.println(bike);

}

}

输出结果

信息: Loading XML bean definitions from class path resource [car.xml]

知其然不知其所以然,大厂常问面试技术如何复习?

1、热门面试题及答案大全

面试前做足功夫,让你面试成功率提升一截,这里一份热门350道一线互联网常问面试题及答案助你拿offer

2、多线程、高并发、缓存入门到实战项目pdf书籍

3、文中提到面试题答案整理

4、Java核心知识面试宝典

覆盖了JVM 、JAVA集合、JAVA多线程并发、JAVA基础、Spring原理、微服务、Netty与RPC、网络、日志、Zookeeper、Kafka、RabbitMQ、Hbase、MongoDB 、Cassandra、设计模式、负载均衡、数据库、一致性算法 、JAVA算法、数据结构、算法、分布式缓存、Hadoop、Spark、Storm的大量技术点且讲解的非常深入

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
img

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
427697261)]

[外链图片转存中…(img-nJkoCUYQ-1713427697261)]

[外链图片转存中…(img-2KBwI10Z-1713427697261)]

3、文中提到面试题答案整理

[外链图片转存中…(img-8ZxlkdN8-1713427697261)]

4、Java核心知识面试宝典

覆盖了JVM 、JAVA集合、JAVA多线程并发、JAVA基础、Spring原理、微服务、Netty与RPC、网络、日志、Zookeeper、Kafka、RabbitMQ、Hbase、MongoDB 、Cassandra、设计模式、负载均衡、数据库、一致性算法 、JAVA算法、数据结构、算法、分布式缓存、Hadoop、Spark、Storm的大量技术点且讲解的非常深入

[外链图片转存中…(img-HLNAkeq1-1713427697262)]

[外链图片转存中…(img-If0sWR5e-1713427697262)]

[外链图片转存中…(img-dKpuJxhm-1713427697262)]

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
[外链图片转存中…(img-fv8ccEMB-1713427697262)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值