初识Spring框架(二)

高通camera调试经验总结 修改AF对焦模式 adb shell setprop vendor.debug.camera.af.manual 2 //使能手动对焦 adb shell setprop vendor.debug.camera.af.manual 0 //使能自动对焦 阅读详情

实现一个简单的Sring实例

1.搭建Spring环境

  新建web项目,引入jar包



2.编写HelloWorld类

package com.array.www.spring;

public class HelloWorld {
	public void show(){
		System.out.println("欢迎学习spring框架");
	}
}

3.配置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" 
		xmlns:context="http://www.springframework.org/schema/context"
		xmlns:tx="http://www.springframework.org/schema/tx"
		xmlns:jaxws="http://cxf.apache.org/jaxws"
		xmlns:soap="http://cxf.apache.org/bindings/soap"
		xsi:schemaLocation="http://www.springframework.org/schema/beans 
					http://www.springframework.org/schema/beans/spring-beans.xsd
					http://cxf.apache.org/bindings/soap 
					http://cxf.apache.org/schemas/configuration/soap.xsd
					http://cxf.apache.org/jaxws 
					http://cxf.apache.org/schemas/jaxws.xsd
					http://www.springframework.org/schema/context
					http://www.springframework.org/schema/context/spring-context.xsd
					http://www.springframework.org/schema/tx
					http://www.springframework.org/schema/tx/spring-tx.xsd">
	
	<bean id="hw" class="com.array.www.spring.HelloWorld">
	</bean>				
</beans>
4.写测试类

package com.array.www.spring.test;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.array.www.spring.HelloWorld;

public class TestDemo {

	public static void main(String[] args) {
		//加载配置文件
		ApplicationContext context = 
				new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
		HelloWorld hw = (HelloWorld) context.getBean("hw");
		hw.show();
	}

}

5.运行结果





EM的理论与实践(基础篇) EM理论与实践 阅读详情

相关推荐

非华为电脑也能用!华为电脑管家完美安装教程来了

GitHub 上有一个开源项目 ​****​,专门解决“非华为设备无法安装华为电脑管家”的问题。它通过智能模拟 + DLL 劫持技术,绕过官方对硬件型号的检测,让你在联想、戴尔、华硕甚至 DIY 主机上也能流畅使用华为电脑管家!⭐ 项目已获 ​700+ Stars​,社区活跃,持续更新,兼容性优秀!科技不该有围墙。如果你成功在非华为电脑上跑起了 PCManager,欢迎在评论区晒出你的设备型号 + 使用体验!也别忘了把这篇推文分享给同样“眼馋”华为生态的朋友 ~📱 ​关注我们。

程序员朱永胜 4957

Spring框架初识(二)

1. AOP的相关概念 1.1 AOP概述 1.1.1 什么是AOP AOP:全程是Aspect Oriented Programming 即面向切面编程。是通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术。AOP是OOP的延续,是软件开发中的一个热点,也是Spring框架中的一个重要内容,是函数式编程的一种衍...

weixin_30780649的博客 98

Unity3d实现的十字路口的模拟(一)

最近学习了Unity3d这个游戏引擎,感觉真的是非常的强大,正好赶上操作系统课程要做一个模拟信号量的模拟程序,于是打算做一个模拟十字路口的程序,大致的实现要实现的成果是:存在四种不同的汽车,包括一辆警车(不受交通信号灯的控制)随机产生在不同的路口,并且有不同的行动路线如:直走,左转,右转等,当然还有交通信号灯来控制车辆的有序运行。可以展示不同的视角来观察路口的情况(利用Q,W,E,R分别控制不同的

永远在身边的专栏 7489

初识Spring Boot框架(二)之DIY一个Spring Boot的自动配置

在上篇博客初识Spring Boot框架中我们初步见识了SpringBoot的方便之处,很多小伙伴可能也会好奇这个spring Boot是怎么实现自动配置的,那么今天我就带小伙伴我们自己来实现一个简单的Spring Boot 自动配置的案例,看看这一切到底是怎么发生的。  假设我的需求是这样的:当我的项目中存在某个类的时候,系统自动为我配置该类的Bean,同时,我这个Bean的属性还可以在a

xxmric的博客 959

华硕电脑Win10改Win7系统:BIOS设置详解

通过上述步骤,华硕电脑用户可以将系统从Windows 10更改为Windows 7。虽然这个过程可能涉及一些技术细节和潜在的风险(如数据丢失和驱动不兼容),但只要按照指南仔细操作并做好准备工作,大多数用户应该能够成功完成系统回滚。请记住,在进行任何系统更改之前都要备份重要数据,并确保已了解所有潜在的风险和限制。希望本文能够帮助到需要回滚到Windows 7的华硕电脑用户!

nntxthml的博客 2262

airodump-ng、aircrack-ng使用教程

wifi破解、airodump-ng、aircrack-ng脚本

ssmbyss的博客 2237

经典三层框架初识(二)---Spring 1.简介

spring简介 什么是spring 产生于2003年,轻量级的javase/ee一站式开源框架. 何为轻量级呢?这个是需要一个参照物的.就是ejb:企业级 javabean javabean:要求就是编写一个类,必须有私有属性,getset方法,还必须有无参构造--其实就是一个满足上面要求的java类,就是javabean 一站式:是在三个层都有自己的框...

XiaodunLP的博客 372

让AI稳定生成流程图:基于Skill与Mermaid的工程化实践

流程图是软件工程中沟通业务逻辑的通用语言,但其绘制与维护却长期依赖手工工具,导致文档更新滞后、协作成本高。随着大语言模型技术的成熟,自然语言生成代码已成为可落地的技术路径,而Mermaid作为一款文本化图表语法,凭借其可版本管理、可自动渲染和可嵌入文档的优势,正逐步取代传统绘图工具。要让AI稳定输出合格的流程图,关键在于为模型定义一套清晰的Skill规则,约束输入结构、处理逻辑和输出格式。本文从流程图的工程痛点出发,介绍如何利用大模型将自然语言描述转化为结构化文本,再通过Mermaid CLI渲染成可视化图

weixin_42548782的博客 314

经典三层框架初识(二)---Spring 2.4 spring整合Junit

一.Junit Junit简介 JUnit是一个Java语言的单元测试框架,用于单元测试. 以前我们测试的时候,一般是单独创建一个测试类,在里面写一个main方法来测试我们的程序,但是实质上这样用main来做测试是不规范的,因为main方式它是一个应用程序的入口,它应该作为主逻辑来运行的,而我们的测试是辅助来做的.其次,一个类只有一个main方法(入口),如果我们现在有很多的代码需要...

XiaodunLP的博客 325

基于FPGA的以太网设计(1)----大白话解释什么是以太网

基于FPGA的千兆以太网设计(1)----大白话解释什么是以太网

孤独的单刀 3878

FPGA实现DDR接口

verilog// DDR2控制器状态机// 初始化序列// 发出初始化命令endendendend// 自动预充电end// 其他状态...endcaseendend。

whm128的博客 1002

经典三层框架初识(二)---Spring 4 Aop

Aop--面向切面编程 采用横向抽取的方式,在运行阶段将增强代码织入目标对象的思想--底层采用动态代理 aop应用场景 事务管理,日志系统,性能监测,缓存等.. aop的框架 1.spring aop(spring-aop.jar) 2.aspectj(aspects.jar) 3.Jboss 我们经常用前俩个 aop专业术语: target:目标对象   代理里...

XiaodunLP的博客 227

uniapp - 解决App端报错reportJSException >>>> exception function:createInstanceContext, exception:white sc

uni-app,安卓Android,苹果ios,安卓app端,苹果App端,uniapp苹果安卓app,uniApp报错,reportJSException>>>>exceptionfunction:createInstanceContext,exception:whitescreencausecreateinstanceContextfailed,运行自定义基座时白屏,uniapp项目运行白屏reportJSException,检查没问题依旧报错,第三方库插件,组件,uniapp打包调试

🏆 前端领域优质创作者 1万+

初识Spring+SpringMVC+MyBatis框架(二)---spring.xml和spring-mvc.xml

上一篇讲了ssm框架搭建

蜂蜂的专栏 649

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

经典三层框架初识(二)---Spring 2.1入门案例1

前面我们简单介绍了一个spring.我们这里主要用spring framew这个框架.主要处理业务逻辑层.我们发现理论恨多,但是其实开发起来代码是很简单的.我们来说一个入门案例. 这里说的入门案例,主要想说下ioc:  控制反转,将对象创建和依赖管理的权限反转给spring容器.这不是第一次强调这个东西了.我们这里再重复一下,就当是强调了.不要嫌我啰嗦.这个思想很重要. 以前我们创建对象都是我...

XiaodunLP的博客 259

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

经典三层框架初识(二)---Spring 2.2入门案例2

前面我们模拟了一下用spring创建dao对象的案例并测试.也就是原来我们数据持久层的代码,我们下面深入一下,我们以前是在表示层就直接调用了下面的数据持久层,但是现在咱们需要业务逻辑层.所以我们用service这层来实现一下业务逻辑层的代码 首先我们还是用原来的传统方式做一下.我们在上面案例的基础上实现 在src下创建一个service的包,里面定义一个UserService接口 pack...

XiaodunLP的博客 241

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

经典三层框架初识(二)---Spring 4 Aop补充--注解实现

下面我们来说一下使用注解实现aop编程.我们在前面的例子基础上修改就好了. 1.目标类对象UserServiceImpl.java 首先UserServiceImpl这个类我们要使用注解实现bean的装配,和前面我们说过的一样.只要在类声明的上面@Service注解就可以了 package service.impl; import org.springframework.stereoty...

XiaodunLP的博客 253

经典三层框架初识(二)---Spring 2.3使用注解实现创建对象

前面我们都是xml配置文件的形式实现bean的装配,接下来我们介绍一下用注解实现bean的装配.和前面的Mybatis一样,使用注解会很方便. 首先我们介绍一下几个注解: @Component  :用于创建对象 就等价于 &lt;bean class=""&gt;&lt;/bean&gt; 注意:前面我们使用xml配置文件要获得对象,如果bean里面没有id值是不能获取的.但是这里@Compo...

XiaodunLP的博客 326

经典三层框架初识(二)---Spring 2.2入门案例2补充

咱们前面说的案例,要给UserServiceImpl中的成员属性UserDao赋值,用的是在UserServiceImpl中创建setter方法.然后在配置文件中配置如下的标签 &lt;bean id="userservice" class="service.impl.UserServiceImpl"&gt; &lt;property name="dao" ref="userdao"&gt;

XiaodunLP的博客 226
上一篇: 初识Spring框架(一)
Array先生
博客等级 码龄10年 1粉丝 8原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值