Gradle 项目 深入解析(三)

夜光序言:

 

 在政客眼中,世上只有两种人,垫脚石和绊脚石。所有可能强过自己的人,都是潜在的威胁~

 

 

正文:

gradle配置文件的介绍

 

SLAM自主导航

我们选择auto-import自动导入

这样就可以从本地仓库导入jar包

/*下面这个是指定中央仓库,可以从中央仓库中进行下载~~
* mavenCentral表示中央仓库嗯*/
repositories {
    mavenCentral()
}

/*gradle所有工程文件都在dependencies里面放置
*每一个jar包的坐标都有三个基本元素组成
* group、name、version这三个嗯
* testCompile只有在测试里面起作用嗯,说到底就是表示的作用域嗯
* 我们在grale里面添加坐标的时候都要带上jar包的作用域* */
dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

附录:maven中央仓库

 

夜光:一步一步添加文件夹、类、接口

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:p="http://www.springframework.org/schema/p"
       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="AccountDao" class="com.Genius.dao.impl.AccountDaoImpl"></bean>

</beans>

 

我们写一个测试类:

package com.Genius.test;

import com.Genius.dao.AccountDao;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AccountTest {

    @Test
    public void accountTest() {
        /*首先我们要得到spring容器*/
        ApplicationContext as = new ClassPathXmlApplicationContext("bean.xml");
        /*从容器中得到AccountDao对象*/
        AccountDao accountDao = as.getBean(AccountDao.class);
        /*接下来就是调用方法*/
        accountDao.findAll();
    }
}

 

夜光:葡萄美酒夜光杯 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值