• Spring项目搭建


    1,新建web项目

    2,导入jar包

    3,编写配置文件

    <?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="userDao" class="com.songyan.demo1.UserDaoImpl" ></bean>
    
    </beans>

    4,新建包

    5,新建接口类

    package com.songyan.demo1;
    
    public interface UserDao {
    public void say();
    }

    6,新建接口的实现类

    package com.songyan.demo1;
    
    
    public class UserDaoImpl implements UserDao{
        public void say()
        {
            System.out.println("UsdeDao say helloWord");
        }
    
    }

    7,编写测试类

    package com.songyan.demo1;
    
    import javax.xml.registry.infomodel.User;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class Test {
    public static void main(String[] args) {
        //初始化容器,加载xml
        ApplicationContext application =new ClassPathXmlApplicationContext("applicationContext.xml");
        //通过容器获取javabean对象实例
        UserDao userDao=(UserDao)application.getBean("userDao");
        //调用实例的方法
        userDao.say();
    }
    }

    8,目录

  • 相关阅读:
    编程之美-2.18 数组分割
    话题模型
    暂时跳过的Leetcode题目
    LDA主题模型
    二叉树非递归的统一实现
    取余和取模运算
    IDM非补丁破解方法
    两种建立堆的方法HeapInsert & Heapify
    非阻塞connect:Web客户程序
    非阻塞connect
  • 原文地址:https://www.cnblogs.com/excellencesy/p/9100022.html
Copyright © 2020-2023  润新知