zoukankan      html  css  js  c++  java
  • Spring_初次体会Spring

    Hello Spring

      需要导入的依赖

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.3.5</version>
    </dependency>
    
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>5.3.5</version>
    </dependency>

      引入配置文件

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
            https://www.springframework.org/schema/beans/spring-beans.xsd">
    
        <bean id="hello" class="com.gazikel.pojo.Hello">
            <property name="str" value="Hello Spring"></property>
        </bean>
    
    </beans>

      当我们想去new一个对象时,我们将这些操作交给spring去做。

    // 获取Spring上下文对象
    ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
    // 我们的对象现在都在spring中管理了, 我们要使用,直接去里面取出来就可以!
    Hello hello = (Hello) context.getBean("hello");
    
    System.out.println(hello.toString());
  • 相关阅读:
    tree-cli 自动生成项目目录结构
    按需导入vant-ui
    全局导入vant-ui
    mook使用流程
    axios使用流程
    Vuex使用流程
    vue-router使用流程
    img的complete和onload
    react-redux 如何在子组件里访问store对象
    ES6中的Export/import操作的是引用
  • 原文地址:https://www.cnblogs.com/Gazikel/p/14907222.html
Copyright © 2011-2022 走看看