当前位置 : 主页 > 手机开发 > harmonyos >

spring基础scope

来源:互联网 收集:自由互联 发布时间:2023-08-26
新建maven项目 导入依赖 dependency groupIdorg.springframework/groupId artifactIdspring-webmvc/artifactId version4.3.6.RELEASE/version /dependency dependency groupIdcommons-logging/groupId artifactIdcommons-logging/artifactId version1


新建maven项目

spring基础scope_java

导入依赖

<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.3.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

Scope.java

package com.shrimpking.scope;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Shrimpking
 * @create 2023/7/5 11:08
 */
public class Scope
{
}

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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="scope" class="com.shrimpking.scope.Scope"/>

</beans>

ScopeTest.java

package com.shrimpking.t1;

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

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Shrimpking
 * @create 2023/7/5 11:10
 */
public class ScopeTest
{
    @Test
    public void test()
    {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        System.out.println(context.getBean("scope"));
        System.out.println(context.getBean("scope"));
    }
}

spring基础scope_xml_02

上一篇:mybatisplus 示例练习4 乐观锁lock
下一篇:没有了
网友评论