广东金东建设工程公司网站asp网站开发pdf

news/2025/9/23 1:13:16/文章来源:
广东金东建设工程公司网站,asp网站开发pdf,搭建一个论坛有什么要求,网站制作软件图标简单手写SpringIOC框架 环境搭建基于XML方式项目结构项目代码运行结果 基于注解方式项目结构项目代码运行结果 简单手写SpringIOC框架核心原理基于XML方式原理项目结构项目代码运行结果 基于注解方式原理项目结构项目代码运行结果 环境搭建 基于XML方式 项目结构 项目代码 p… 简单手写SpringIOC框架 环境搭建基于XML方式项目结构项目代码运行结果 基于注解方式项目结构项目代码运行结果 简单手写SpringIOC框架核心原理基于XML方式原理项目结构项目代码运行结果 基于注解方式原理项目结构项目代码运行结果 环境搭建 基于XML方式 项目结构 项目代码 pom.xml ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom/groupIdartifactIdspring/artifactIdversion1.0-SNAPSHOT/versionpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.springframework/groupIdartifactIdspring-core/artifactIdversion5.2.1.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-beans/artifactIdversion5.2.1.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion5.2.1.RELEASE/version/dependency/dependencies/projectUserBean.java package com.spring.bean;/*** author honey* date 2023-08-08 14:58:16*/ public class UserBean { }spring.xml ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdbean iduserBean classcom.spring.bean.UserBean//beansSpringTest01.java package com.spring.test;import com.spring.bean.UserBean; import org.springframework.context.support.ClassPathXmlApplicationContext;/*** author honey* date 2023-08-08 14:59:56*/ public class SpringTest01 {public static void main(String[] args) {// 读取spring.xmlClassPathXmlApplicationContext applicationContext new ClassPathXmlApplicationContext(spring.xml);// 从IOC容器中读取对象UserBean userBean applicationContext.getBean(userBean, UserBean.class);System.out.println(userBean);} }运行结果 基于注解方式 项目结构 项目代码 ScanBean.java package com.spring.bean.scan;import org.springframework.stereotype.Component;/*** author honey* date 2023-08-08 16:37:26*/ Component public class ScanBean { }SpringConfig.java package com.spring.config;import com.spring.bean.UserBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration;/*** author honey* date 2023-08-08 16:30:21*/ Configuration ComponentScan(value {com.spring.bean.scan}) public class SpringConfig {Bean(name user)public UserBean userBean() {return new UserBean();} }SpringTest02.java package com.spring.test;import com.spring.bean.UserBean; import com.spring.bean.scan.ScanBean; import com.spring.config.SpringConfig; import org.springframework.context.annotation.AnnotationConfigApplicationContext;/*** author honey* date 2023-08-08 16:31:25*/ public class SpringTest02 {public static void main(String[] args) {// 加载SpringConfigAnnotationConfigApplicationContext applicationContext new AnnotationConfigApplicationContext(SpringConfig.class);// 从IOC容器中读取对象UserBean userBean applicationContext.getBean(user, UserBean.class);System.out.println(userBean);ScanBean scanBean applicationContext.getBean(scanBean, ScanBean.class);System.out.println(scanBean);} }运行结果 简单手写SpringIOC框架 核心原理 底层使用map集合管理对象keybeanIdvalue实例对象 private final MapString, Object beanMap new ConcurrentHashMap();基于XML方式 原理 基于反射工厂模式DOM技术 使用DOM技术解析spring.xml文件获取bean的id和class属性根据类的完整路径使用反射技术初始化对象使用工厂模式管理初始化对象 项目结构 项目代码 pom.xml ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom/groupIdartifactIdext-spring-ioc/artifactIdversion1.0-SNAPSHOT/versionpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.springframework/groupIdartifactIdspring-core/artifactIdversion5.2.1.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-beans/artifactIdversion5.2.1.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion5.2.1.RELEASE/version/dependencydependencygroupIddom4j/groupIdartifactIddom4j/artifactIdversion1.6.1/version/dependency/dependencies/projectUserBean.java package com.spring.bean;/*** author honey* date 2023-08-08 16:56:32*/ public class UserBean { }spring.xml ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdbean iduserBean classcom.spring.bean.UserBean//beansSpringIocXml.java package com.spring.ext;import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; import org.springframework.core.io.ClassPathResource;import java.io.File; import java.io.IOException; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap;/*** author honey* date 2023-08-08 16:57:17*/ public class SpringIocXml {private final MapString, Object beanMap new ConcurrentHashMap();public SpringIocXml() throws IOException, DocumentException {init();}public T T getBean(String name) {return (T) beanMap.get(name);}/*** 初始化IOC容器*/private void init() throws IOException, DocumentException {// 解析spring.xml配置ClassPathResource classPathResource new ClassPathResource(spring.xml);File xmlFile classPathResource.getFile();SAXReader saxReader new SAXReader();Document doc saxReader.read(xmlFile);// 获取根节点Element rootElement doc.getRootElement();// 获取bean节点信息ListElement beans rootElement.elements(bean);for (Element bean : beans) {try {String beanId bean.attribute(id).getValue();String classPath bean.attribute(class).getValue();// 使用反射机制初始化对象并将对象存入Map集合Class? clazz Class.forName(classPath);Object object clazz.newInstance();beanMap.put(beanId, object);} catch (Exception e) {e.printStackTrace();}}}}SpringTest01.java package com.spring.test;import com.spring.bean.UserBean; import com.spring.ext.SpringIocXml; import org.dom4j.DocumentException;import java.io.IOException;/*** author honey* date 2023-08-08 17:04:35*/ public class SpringTest01 {public static void main(String[] args) throws DocumentException, IOException {SpringIocXml springIocXml new SpringIocXml();UserBean userBean springIocXml.getBean(userBean);System.out.println(userBean);} }运行结果 基于注解方式 原理 基于反射工厂模式实现 判断配置类上是否有Configuration注解获取配置类中的所有方法判断方法上是否有Bean注解如果有则获取方法的返回值作为实例对象判断配置类上是否有ComponentScan注解如果有则扫描指定包下的所有类并判断类上是否有Component注解如果有则通过反射技术初始化对象使用工厂模式管理初始化对象/实例对象 项目结构 项目代码 pom.xml dependencygroupIdcn.hutool/groupIdartifactIdhutool-all/artifactIdversion5.7.7/version /dependencyScanBean.java package com.spring.bean.scan;import org.springframework.stereotype.Component;/*** author honey* date 2023-08-09 14:28:33*/ Component public class ScanBean { }SpringConfig.java package com.spring.config;import com.spring.bean.UserBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration;/*** author honey* date 2023-08-09 14:26:40*/ Configuration ComponentScan(value {com.spring.bean.scan}) public class SpringConfig {Beanpublic UserBean userBean() {return new UserBean();} }SpringIocAnnotation.java package com.spring.ext;import cn.hutool.core.lang.ClassScanner; import cn.hutool.core.util.StrUtil; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component;import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap;/*** author honey* date 2023-08-09 14:12:21*/ public class SpringIocAnnotation {private final Object config;private final MapString, Object beanMap new ConcurrentHashMap();public SpringIocAnnotation(Object config) {this.config config;init();}/*** 初始化IOC容器*/public void init() {// 判断配置类上是否有Configuration注解Configuration configuration this.config.getClass().getDeclaredAnnotation(Configuration.class);if (configuration null) {return;}// 处理Bean注解Class? clazz config.getClass();Method[] declaredMethods clazz.getDeclaredMethods();for (Method method : declaredMethods) {// 判断方法上是否有Bean注解Bean bean method.getDeclaredAnnotation(Bean.class);if (bean ! null) {try {// 获取beanIdString[] value bean.value();String beanId value.length 0 ? value[0] : method.getName();// 获取方法的返回值Object object method.invoke(config);beanMap.put(beanId, object);} catch (Exception e) {e.printStackTrace();}}}// 处理Component注解ComponentScan componentScan clazz.getDeclaredAnnotation(ComponentScan.class);if (componentScan ! null) {for (String packageName : componentScan.value()) {try {// 扫描指定包下的所有类SetClass? classes ClassScanner.scanPackage(packageName);for (Class? c : classes) {// 判断类上是否有Component注解Annotation component c.getDeclaredAnnotation(Component.class);if (component ! null) {try {// 获取beanIdString beanId StrUtil.lowerFirst(c.getSimpleName());// 通过反射技术初始化对象Object beanObject c.newInstance();beanMap.put(beanId, beanObject);} catch (Exception e) {e.printStackTrace();}}}} catch (Exception e) {e.printStackTrace();}}}}public T T getBean(String name) {return (T) beanMap.get(name);} }SpringTest02.java package com.spring.test;import com.spring.bean.UserBean; import com.spring.bean.scan.ScanBean; import com.spring.config.SpringConfig; import com.spring.ext.SpringIocAnnotation;/*** author honey* date 2023-08-09 14:24:36*/ public class SpringTest02 {public static void main(String[] args) {SpringIocAnnotation springIocAnnotation new SpringIocAnnotation(new SpringConfig());UserBean userBean springIocAnnotation.getBean(userBean);System.out.println(userBean);ScanBean scanBean springIocAnnotation.getBean(scanBean);System.out.println(scanBean);} }运行结果

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/910968.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

陕西建设厅网站人才库外包人力资源公司

一、GAN原理 出发点:机器学习中生成模型的问题 无监督学习是机器学习和未来人工智能的突破点,生成模型是无监督学习的关键部分 特点: 不需要MCMC或者变分贝叶斯等复杂的手段,只需要在G和D中对应的多层感知机中运行反向传播或者…

郑州网站设计网站宝安做网站的公司

头文件如://#include //包含库函数............//............_nop_(); //引用库函数敬礼。我一直都是借助仿真软件编。一点一点试时间。C语言最大的缺点就是实时性差,我在网上到看了一些关于延时的讨论,其中有篇文章51单片机 Keil C 延时程序的简单研究,…

ps制作博客网站界面网上做问卷报酬不错的网站是

ZAB协议 ZAB协议是如何实现操作地顺序性的? 如果用一句话解释ZAB协议到底是什么,我觉得它是能保证操作顺序性的、基于主备模式的原子广播协议。 接下来,还是以指令X、Y为例具体演示一下,帮助你更好地理解为什么ZAB协议能实现操作…

测试测试测试测试测试

欢迎使用 OpenWrite 开始写作您的文章... 这是一个二级标题 您可以使用 Markdown 语法:粗体文字 斜体文字 行内代码// 代码块示例 console.log(Hello OpenWrite!);这是一个引用块链接示例

Day008 循环结构与breakcontinue - Java流程控制

Day008 循环结构与break&continue - Java流程控制$(".postTitle2").removeClass("postTitle2").addClass("singleposttitle");Java流程控制 循环结构 (1)while循环while是最基本的…

com域名和网站wordpress顶部提示

FOTA模块中OTA的知识点:1.测试过程中发现哪几类问题? 可能就是一个单键的ecu,比如升了一个门的ecu,他的升了之后就关不上,还有就是升级组合ecu的时候,c屏上不显示进度条。 2.在做ota测试的过程中&#xff…

模板网站的好处网络营销方案策划论文

中霖教育怎么样?中霖教育好吗? 中霖教育包括师资力量、课程设置、教学方法等都是经过不断完善来制定的,我们拥有专业且经验丰富的师资队伍,在教学过程中更注重个性化教学方式,针对每个学员的需求和学习情况制定专属的学习计划。 无论是在…

广西区建设厅网站小制作的制作过程

Posix在线文档: The Single UNIX Specification, Version 2 (opengroup.org) Linux系统中提供了两种不同接口的消息队列: POSIX消息队列。POSIX为可移植的操作系统接口。System V消息队列。System V 是 AT&T 的第一个商业UNIX版本(UNIX System III)的…

呼和浩特 的网站建设上海专业网站建设网

这是记录前端面试的话术集锦第十五篇博文——高频考点(React常考进阶知识点),我会不断更新该博文。❗❗❗ 1. HOC 是什么?相比 mixins 有什么优点? 很多人看到高阶组件(HOC)这个概念就被吓到了,认为这东西很难,其实这东西概念真的很简单,我们先来看一个例子: func…

如何做一名合格的网站人静态网页设计与制作

🌈个人主页:SKY-30 ⛅个人推荐:基于java提供的ArrayList实现的扑克牌游戏 |C贪吃蛇详解 ⚡学好数据结构,刷题刻不容缓:点击一起刷题 🌙心灵鸡汤:总有人要赢,为什么不能是我呢 &…

建立网站大概需要多长时间丹阳火车站片区规划

非类型模板参数 模板参数分为类型形参与非类型形参 。 类型形参即:出现在模板参数列表中,跟在 class 或者 typename 之类的参数类型名称 。 非类型形参,就是用一个常量作为类 ( 函数 ) 模板的一个参数,在类 ( 函数 ) 模板中可将…

网站专题怎么做呢广州页面制作公司

从 NS-10M 监听音箱到 MSP 系列和 HS 系列,雅马哈始终秉持忠实的设计理念,聚焦声学精度,为音频专家提供出色的平台,构建并成就他们专属的专业之声。MT7录音室监听耳机承袭了这一基本研发理念,重现最为精细的声音,力求满…

capacitor的android项目接入穿山甲遇到的坑

Caused by: java.lang.ClassNotFoundException: Didnt find class "com.bytedance.sdk.openadsdk.TTFileProvider" on path: DexPathList[[zip file "/data/app/~~Ol1vZKiGBPJT4eFuTS5Zyw==/org.capaci…

网站建设的看法有哪些后端和前端哪个前景好

一.四种模型 阻塞式IO,非阻塞式IO,信号驱动IO,IO多路复用 二.阻塞式IO 特点:最简单,最常用,效率低 阻塞I/O 模式是最普遍使用的I/O 模式 系统默认状态,套接字建立后所处于的模式就是阻塞I/O 模式…

网站建设运营策划方案建站行业乱象完整版

文章目录 0 引入1、带有标尺的温度/湿度计控件1.头文件2.核心代码 2、竖起来的温度/湿度计控件1.头文件2.实现 3、引用 0 引入 QT原生控件没有实现如仪表盘或者温度计的控件,只好自己实现,文章代码部分参考引用的文章。直接上图 图一 带有标尺的温度计…

新建网站的步骤阿里云搜索引擎入口

目录 前言 一、fsck命令 1、HDFS副本块数量的配置 2、fsck命令查看文件的副本数 3、block配置 二、NameNode元数据 1、edits文件 2、fsigame文件 3、NameNode元数据管理维护 4、元数据合并控制参数 5、SecondaryNameNode的作用 三、HDFS数据的读写流程 1、数据写入…

网络优化推广 网站开发建设重庆seo优化公司

正文 大约在五六年前,第一次接触到了当时已经是hot topic的NoSql。不过那个时候学的用的都是mysql,Nosql对于我而言还是新事物,并没有真正使用,只是不明觉厉。但是印象深刻的是这么一张图片(后来google到图片来自这里&…

做网站需要多少带宽点播视频网站怎么建设

实验报告题目: 内核模块实验1、实验目的模块是Linux系统的一种特有机制,可用以动态扩展操作系统内核功能。编写实现某些特定功能的模块,将其作为内核的一部分在管态下运行。本实验通过内核模块编程在/porc文件系统中实现系统时钟的读操作接口。2、实验内…

怎么区分营销型网站个人宽带 架设网站需备案

本文翻译自 Reduce the scope and complexity of style calculations,作者:Jeremy Wagner, 略有删改。 JavaScript通常用来改变页面的视觉效果。比如通过改变style样式或者通过计算后改变页面布局,比如搜索或排序数据。长时间运行…

增加网站访客wordpress蜘蛛插件

一、环境QT版本:QT 5.8.0(msvc2013_64)MySQL版本:mysql 5.7.19二、配置之前 mysql 数据库一直都连接不上,网上也搜了很多资料,主要还是库文件的问题。重新将 mysql.pro 编译一下,将生成的 .dll 和 .lib 文件拷贝到 QT …