首页 > 编程语言 >Spring源码环境搭建

Spring源码环境搭建

时间:2022-08-17 20:56:38浏览次数:70  
标签:name String spring class Person 源码 Spring public 搭建

Spring源码在github上,地址是https://github.com/spring-projects/spring-framework/,选择5.3.x版本,直接从github上克隆项目网速很慢,所以首先将github上的Spring项目导入gitee仓库里,再从gitee克隆项目。

克隆项目后,等待项目构建完毕,时间可能比较长。

新建一个gradle模块myselft-test

在settings.gradle文件加入
include 'myselft-test'

在myselft-test模块build.gradle加入
implementation project(":spring-context")
implementation project(":spring-beans")

在resources目录新建app.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:aop="http://www.springframework.org/schema/aop"
	   xmlns:context="http://www.springframework.org/schema/context"
	   xmlns:mvc="http://www.springframework.org/schema/mvc"
	   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
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd">


	<beans>
		<bean id="person" class="xml.Person">
			<property value="张三" name="name"></property>
		</bean>
	</beans>
</beans>

新建Person.class

点击查看代码
public class Person {
	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}

测试

点击查看代码
public class Main {
	public static void main(String[] args) {
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:app.xml");
		Person person = applicationContext.getBean(Person.class);
		System.out.println(person.getName());
	}
}

执行结果:

标签:name,String,spring,class,Person,源码,Spring,public,搭建
From: https://www.cnblogs.com/shigongp/p/16596697.html

相关文章

  • 【CV源码项目实现】darknet中network的实现过程
     darknet的网络结构使用network结构体进行保存,network的构建过程主要包括以下几个函数:load_network(src/networks.c)----->parse_network_cfg(src/parser.c) --->ma......
  • 【CV项目源码实现】Floating point exception (core dumped)
    前言cmd./darknetdetectordemocfg/tfl.datacfg/yolov3-tiny-tfl.cfgbackup/yolov3-tiny-tfl_500000.weightsdata/tfl.avierrorFloatingpointexception(cor......
  • SpringBoot 多线程
    关于SpringBoot中多线程的两个注解:@Async是spring为了方便开发人员进行异步调用而出现的。在方法上加入这个注解,spring会从线程池中获取一个新的线程来执行方法,实现异步调......
  • Shardingsphere-ShardingSphere-JDBC-Spring Boot配置-分片规则
    spring.shardingsphere.datasource.names=#省略数据源配置,请参考用法#标准分表配置spring.shardingsphere.rules.sharding.tables.<table-name>.actual-data-nodes=#......
  • Spring MVC
    Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架。什么是SpringMVC?SpringMVC是一个基于Java的实现了MVC设计模式的请求驱动类型的轻量级Web框架,通过把Mod......
  • 内网搭建DNS服务器
    docker使用ubuntu镜像搭建DNS服务DNS方案选择实现dns常见的软件有bind9、coredns(k8s中使用的)、DNSmasq。等这里选择bind9配置#配置清单dnsserverip:172.......
  • 在linux服务器上搭建FTP服务器
    一、在Linux服务器上安装vsftpyum-yinstallvsftpd二、编辑vsftp.conf文件 参数作用listen=[YES|NO]是否以独立运......
  • SpringBoot使用Log4J2
    一、常用日志框架Log4j:Apache的一个开源项目,可以控制日志信息输送的目的地是控制台、文件、GUI组件等,可以控制每一条日志的输出格式,这些可以通过一个配置文件来灵活地进......
  • SpringCloudAlibaba-注册中心_配置中心(Nacos)
    Nacos概述为什么叫Nacos?前4个分别为Naming和Configuration的前2个字母,s是Service;what Dynamic Namingand Configuration Service一个更易于构建云原生应用的......
  • 关系不明组件间的通信PubSub(发布订阅的使用步骤+ps源码)
    1、安装  npmipubsub-js2、在main.js中引入并加入到全局  3、在组件中发布:使用publish(自定义名称,传参)  4、在组件中接收:在mounted中使用subscribe,在befor......