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

织梦网站联系我们的地图怎么做北京效果好的网站推广

织梦网站联系我们的地图怎么做,北京效果好的网站推广,网站做315认证,免费购物系统目录 一、ClassPathXmlApplicationContext1.1 说明1.2 代码示例1.3 截图示例 二、FileSystemXmlApplicationContext2.1 说明2.2 代码示例2.3 加载xml的bean定义示例 三、AnnotationConfigApplicationContext3.1 说明3.2 代码示例3.3 截图示例 四、AnnotationConfigServletWebSe… 目录 一、ClassPathXmlApplicationContext1.1 说明1.2 代码示例1.3 截图示例 二、FileSystemXmlApplicationContext2.1 说明2.2 代码示例2.3 加载xml的bean定义示例 三、AnnotationConfigApplicationContext3.1 说明3.2 代码示例3.3 截图示例 四、AnnotationConfigServletWebServerApplicationContext4.1 说明4.2 代码示例4.2 截图示例 一、ClassPathXmlApplicationContext 1.1 说明 1. 较为经典的容器基于classpath下xml格式的配置文件来创建 2. 在类路径下读取xml文件 3. 现在已经很少用了做个了解 1.2 代码示例 1. 学生类 package com.learning.application_context;public class Student {private Card card;public void setCard(Card card){this.card card;}public Card getCard(){return this.card;} } 2. 卡类 package com.learning.application_context;public class Card { } 3. 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 idcard classcom.learning.application_context.Card/bean idstudent classcom.learning.application_context.Studentproperty namecard refcard/property/bean /beans4. 测试类 package com.learning.application_context;import org.springframework.context.support.ClassPathXmlApplicationContext;public class ApplicationContextTest {public static void main(String[] args) {testClassPathXmlApplicationContext();}private static void testClassPathXmlApplicationContext(){ClassPathXmlApplicationContext classPathXmlApplicationContext new ClassPathXmlApplicationContext(class-path-xml-application-context.xml);for (String beanDefinitionName : classPathXmlApplicationContext.getBeanDefinitionNames()) {System.out.println(beanDefinitionName);}System.out.println(classPathXmlApplicationContext.getBean(Student.class).getCard());} } 1.3 截图示例 二、FileSystemXmlApplicationContext 2.1 说明 1. 基于读取文件系统的xml来创建 2.2 代码示例 package com.learning.application_context;import org.springframework.context.support.FileSystemXmlApplicationContext;public class ApplicationContextTest {public static void main(String[] args) {testFileSystemXmlApplicationContext();}private static void testFileSystemXmlApplicationContext(){// 具体配置的路径按实际情况来写FileSystemXmlApplicationContext fileSystemXmlApplicationContext new FileSystemXmlApplicationContext(D:\\IdeaProject\\spring-framework\\spring-learning\\src\\main\\resources\\class-path-xml-application-context.xml);for (String beanDefinitionName : fileSystemXmlApplicationContext.getBeanDefinitionNames()) {System.out.println(beanDefinitionName);}System.out.println(fileSystemXmlApplicationContext.getBean(Student.class).getCard());} } private static void testFileSystemXmlApplicationContext(){// 绝对目录 // FileSystemXmlApplicationContext fileSystemXmlApplicationContext new FileSystemXmlApplicationContext(D:\\IdeaProject\\spring-framework\\spring-learning\\src\\main\\resources\\class-path-xml-application-context.xml);// 相对目录,但要设置工作目录FileSystemXmlApplicationContext fileSystemXmlApplicationContext new FileSystemXmlApplicationContext(src\\main\\resources\\class-path-xml-application-context.xml);for (String beanDefinitionName : fileSystemXmlApplicationContext.getBeanDefinitionNames()) {System.out.println(beanDefinitionName);}System.out.println(fileSystemXmlApplicationContext.getBean(Student.class).getCard());}2.3 加载xml的bean定义示例 package com.learning.application_context;import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.ClassPathResource;public class ApplicationContextTest {public static void main(String[] args) {loadXmlBeanDefinitionTest();}private static void loadXmlBeanDefinitionTest(){DefaultListableBeanFactory defaultListableBeanFactory new DefaultListableBeanFactory();System.out.println(读取前的BeanDefinitionName);for (String beanDefinitionName : defaultListableBeanFactory.getBeanDefinitionNames()) {System.out.println(beanDefinitionName);}XmlBeanDefinitionReader xmlBeanDefinitionReader new XmlBeanDefinitionReader(defaultListableBeanFactory);xmlBeanDefinitionReader.loadBeanDefinitions(new ClassPathResource(class-path-xml-application-context.xml));System.out.println(读取后的BeanDefinitionName);for (String beanDefinitionName : defaultListableBeanFactory.getBeanDefinitionNames()) {System.out.println(beanDefinitionName);}} } 三、AnnotationConfigApplicationContext 3.1 说明 1. 较为经典的容器基于java配置类来创建 2. 会默认添加几个后处理器org.springframework.context.annotation.internalConfigurationAnnotationProcessor org.springframework.context.annotation.internalAutowiredAnnotationProcessor org.springframework.context.annotation.internalCommonAnnotationProcessor org.springframework.context.event.internalEventListenerProcessor org.springframework.context.event.internalEventListenerFactory 3. 用xml的方式是用context:annotation-config/来添加的 3.2 代码示例 package com.learning.application_context;import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;Configuration public class Config {Beanpublic Student student(Card card){Student student new Student();student.setCard(card);return student;}Beanpublic Card card(){return new Card();} } package com.learning.application_context;import org.springframework.context.annotation.AnnotationConfigApplicationContext;public class ApplicationContextTest {public static void main(String[] args) {testAnnotationConfigApplicationContext();}private static void testAnnotationConfigApplicationContext(){AnnotationConfigApplicationContext annotationConfigApplicationContext new AnnotationConfigApplicationContext(Config.class);for (String beanDefinitionName : annotationConfigApplicationContext.getBeanDefinitionNames()) {System.out.println(beanDefinitionName);}} } 3.3 截图示例 四、AnnotationConfigServletWebServerApplicationContext 4.1 说明 1. 可以加载tomcat服务来工作2. 需要加载springboot相关的jar包 4.2 代码示例 package com.learning.application_context;import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletRegistrationBean; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.Controller;import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;Configuration public class WebConfig {// 定义一个tomcat服务工厂Beanpublic ServletWebServerFactory servletWebServerFactory(){return new TomcatServletWebServerFactory();}Beanpublic DispatcherServlet dispatcherServlet(){return new DispatcherServlet();}Beanpublic DispatcherServletRegistrationBean registrationBean(DispatcherServlet dispatcherServlet){return new DispatcherServletRegistrationBean(dispatcherServlet, /);}Bean(/hello)public Controller controllerOne(){return new Controller() {Overridepublic ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {httpServletResponse.getWriter().print(hello);return null;}};} } package com.learning.application_context;import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletRegistrationBean; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.Controller;import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;Configuration public class WebConfig {// 定义一个tomcat服务工厂Beanpublic ServletWebServerFactory servletWebServerFactory(){return new TomcatServletWebServerFactory();}Beanpublic DispatcherServlet dispatcherServlet(){return new DispatcherServlet();}Beanpublic DispatcherServletRegistrationBean registrationBean(DispatcherServlet dispatcherServlet){return new DispatcherServletRegistrationBean(dispatcherServlet, /);}Bean(/hello)public Controller controllerOne(){return new Controller() {Overridepublic ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {httpServletResponse.getWriter().print(hello);return null;}};} } 4.2 截图示例
http://www.pierceye.com/news/131577/

相关文章:

  • 国内永久免费crm系统网站推荐做网站需要学些什么软件
  • 做网站 怎么备案怎么用qq相册做网站
  • 网站建设 公众号免费的网站怎么做
  • 深圳公司网站设计公太原企业网站建设
  • 营销型网站的分类公众号开发信息什么意思
  • 爱写作网站最佳wordpress主机
  • 东山网站制作一站式做网站费用
  • seo针对网站做策划外贸淘宝网站建设
  • 电商网站的建设与运营百度推广营销怎么做
  • 做网站的核验单 是下载的吗北京建设工程招标公告网站
  • 网站建设与维护试卷第九章各网站文风
  • 熊掌号网站的基础建设费用网站的建设ppt模板
  • 有口碑的坪山网站建设王野天 演员
  • 建e网怎么赚钱衡水网站优化
  • 做牙科设计的网站域名一定要备案才能用吗
  • 哪个网站做团购要求低点河北省住房和城乡建设厅网站
  • 华为商城网站建设世界杯大数据
  • 网站流量指标高埗镇仿做网站
  • 网站建设颊算校园网站的作用
  • 云南公司网站制作外贸网站推广外包
  • 甘肃住房建设厅的网站数据中心idc机房
  • wordpress开发视频网站模板下载wordpress qq 微信登录
  • 上海网站建设网站营销推广费计入什么科目
  • 云南培训网站建设网站建设的公司太多了
  • 洛阳网站建设招聘信息ppt设计师兼职
  • 建工网官方网站电子商务网站设计岗位主要是
  • 保险网站建设平台青岛设计公司排名
  • 伊利网站建设评价做的最好的宠物网站
  • 沈阳的网站制作公司哪家好常用设计资源网站
  • 做网站需要什么技术文化传媒公司 网站备案