当前位置: 首页 > news >正文

秦皇岛陵县网站建设WordPress去掉你的位置

秦皇岛陵县网站建设,WordPress去掉你的位置,网站建设费属于广告费用吗,建网站电话Spring基础 - Spring简单例子引入Spring要点 设计一个Spring的Hello World 设计一个查询用户的案例的两个需求#xff0c;来看Spring框架帮我们简化了什么开发工作 pom依赖 ?xml version1.0 encodingUTF-8? project xmlnshtt…Spring基础 - Spring简单例子引入Spring要点 设计一个Spring的Hello World 设计一个查询用户的案例的两个需求来看Spring框架帮我们简化了什么开发工作 pom依赖 ?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/modelVersiongroupIdtech.pdai/groupIdartifactIdspring_framework_demo_hellowrold_xml/artifactIdversion1.0-SNAPSHOT/versionpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.targetspring.version5.3.9/spring.versionaspectjweaver.version1.9.6/aspectjweaver.version/propertiesdependenciesdependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-core/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-beans/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.aspectj/groupIdartifactIdaspectjweaver/artifactIdversion${aspectjweaver.version}/version/dependency/dependencies/project 工程整体框架如下 App package tech.pdai.springframework;import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import tech.pdai.springframework.entity.User; import tech.pdai.springframework.service.UserServiceImpl;import java.util.List;/*** author pdai*/ public class App {/*** main interfaces.** param args args*/public static void main(String[] args) {// create and configure beansApplicationContext context new ClassPathXmlApplicationContext(aspects.xml, daos.xml, services.xml);// retrieve configured instance// 将原有的Bean的创建工作转给框架 需要用时从Bean的容器中获取即可简化开发工作UserServiceImpl service context.getBean(userService, UserServiceImpl.class);// use configured instanceListUser userList service.findUserList();// print info from beans // userList.forEach(a - System.out.println(a.getName() , a.getAge()));} } 有了Spring框架可以将原有Bean的创建工作转给框架, 需要用时从Bean的容器中获取即可这样便简化了开发工作 总结 Spring框架管理这些Bean的创建工作用户管理Bean转变为框架管理Bean,这个叫做控制翻转 IOC Inversion Of ControlSpring框架托管创建的Bean放在IOC ContainerSpring框架为了更好的让用户配置Bean必然会引入不同方式来配置Bean这便是xml配置 Java配置 注解配置Spring框架既然接管了bean的生成必然需要管理整个Bean的生命周期应用程序代码从IOC Container中获取依赖的bean注入到引用程序中这个过程称之为依赖注入控制翻转是通过依赖注入实现的依赖注入有哪些方式AutoWired Resource Qualifier 同时Bean之间存在依赖存在先后顺序问题以及循环依赖问题 面向切面 - AOP 有了Spring框架通过Aspect注解 定义切面切面中定义拦截所有service的方法 并记录日志框架将日志记录和业务需求的代码解耦了 不再是侵入式了 package tech.pdai.springframework.aspect;import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.reflect.MethodSignature;import java.lang.reflect.Method;/*** author pdai 拦截所以service方法*/ Aspect public class LogAspect {/*** aspect for every methods under service package.*/Around(execution(* tech.pdai.springframework.service.*.*(..)))public Object businessService(ProceedingJoinPoint pjp) throws Throwable {// get attribute through annotationMethod method ((MethodSignature) pjp.getSignature()).getMethod();System.out.println(execute method: method.getName());// continue to processreturn pjp.proceed();}} Spring框架通过定义切面通过拦截切点实现不同业务模块的解耦这个叫做面向切面编程AOP如何实现AOP:代理技术分为静态代理和动态代理动态代理包含JDK代理和CGLIB代理 Spring框架设计如何逐步简化开发的 注解配置方式改造 BeanConfig 不再需要Java配置 package tech.pdai.springframework.config;import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScans; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy;/*** author pdai*/ Configuration EnableAspectJAutoProxy public class BeansConfig {} UserDaoImpl 增加了 Repository注解 /*** author pdai*/ Repository public class UserDaoImpl {/*** mocked to find user list.** return user list*/public ListUser findUserList() {return Collections.singletonList(new User(pdai, 18));} } UserServiceImpl 增加了Service 注解并通过Autowired注入userDao. package tech.pdai.springframework.service;import java.util.List;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import tech.pdai.springframework.dao.UserDaoImpl; import tech.pdai.springframework.entity.User;/*** author pdai*/ Service public class UserServiceImpl {/*** user dao impl.*/Autowiredprivate UserDaoImpl userDao;/*** find user list.** return user list*/public ListUser findUserList() {return userDao.findUserList();}} 在App中扫描tech.pdai.springframework包 package tech.pdai.springframework;import java.util.List;import org.springframework.context.annotation.AnnotationConfigApplicationContext; import tech.pdai.springframework.entity.User; import tech.pdai.springframework.service.UserServiceImpl;/*** author pdai*/ public class App {/*** main interfaces.** param args args*/public static void main(String[] args) {// create and configure beansAnnotationConfigApplicationContext context new AnnotationConfigApplicationContext(tech.pdai.springframework);// retrieve configured instanceUserServiceImpl service context.getBean(UserServiceImpl.class);// use configured instanceListUser userList service.findUserList();// print info from beansuserList.forEach(a - System.out.println(a.getName() , a.getAge()));} } SpringBoot托管配置 Springboot实际上通过约定大于配置的方式使用xx-starter统一的对Bean进行默认初始化用户只需要很少的配置就可以进行开发了。
http://www.zqtcl.cn/news/909442/

相关文章:

  • 网络教学平台昆明理工大学优化大师的功能有哪些
  • 个人主题网站做的步骤一流的网站建设
  • 公司网站建设规划国外搜索关键词的网站
  • 石家庄网站快速优化排名国内做性视频网站有哪些
  • 易居做网站网页设计的发展
  • 开一个网站建设公司好产品销售型的网站
  • 苍梧县网站建设南京网站建设 雷仁网络
  • 四川网站制作成都wordpress 移动支付
  • 山西网站开发二次开发做自媒体可以参考的外国网站
  • 合肥 网站设计大学生创新创业大赛项目计划书
  • 北京网站主题制作做婚恋网站怎么样
  • 卖设计图的网站低代码开发平台公司
  • 建设银行顺德分行网站中国建筑装饰公司排名
  • 百度网站提交入口百度国内打开google网页的方法
  • 上海高端品牌网站制作wordpress返利主题
  • 网站建设会遇到哪些难题安阳网站如何做优化
  • 哈德网站建设使用wordpress创建企业官网
  • 新品销售网站建设建设银行网站怎么登陆密码
  • 外贸营销主题怎么写seo薪资
  • 手机音乐网站源码关键路径
  • 网站制作哪些官方静态网站模板
  • 网站开发seo网站排名优化服务
  • 佛山营销网站开发帝国cms网站公告怎么做
  • 2_试列出网站开发建设的步骤在哪里进行网站域名的实名认证
  • 个人网站做博客还是做论坛网络服务推广
  • 遵义网站制作小程序辛集做网站
  • 做逆战网站的名字吗网站维护员
  • 浏览器收录网站重庆网上房地产网
  • 门户网站建设哪专业wordpress爆破密码字典
  • 响应式网站的制作app开发公司加盟