标签:sch expr 注解 系统 ble package source pat string
package com.gychen.po;
import java.io.Serializable;
public class ClassInfo implements Serializable {
private Integer id;
private String name;
private String remarks;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
}
package com.gychen.dao;
import com.gychen.po.ClassInfo;
import java.util.List;
public interface ClassInfoDao {
/**
* 查询所有图书类型信息
*/
List<ClassInfo> queryClassInfoAll();
}
package com.gychen.service;
import com.gychen.po.ClassInfo;
import java.util.List;
public interface ClassInfoService {
/**
* 查询所有的图书类型信息
*/
List<ClassInfo> queryClassInfoAll();
}
package com.gychen.service;
import com.gychen.po.ClassInfo;
import java.util.List;
public class ClassInfoServiceImpl implements ClassInfoService {
@Override
public List<ClassInfo> queryClassInfoAll() {
// 没有连接数据库,以打印控制台代替
System.out.println("查询到了所有的图书类型.......");
return null;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 开启注解扫描 处理service层和dao层 controller层不处理-->
<context:component-scan base-package="com.gychen">
<!-- 配置不扫描的 -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>
package com.gychen.service;
import com.gychen.po.ClassInfo;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("classInfoService")
public class ClassInfoServiceImpl implements ClassInfoService {
@Override
public List<ClassInfo> queryClassInfoAll() {
// 没有连接数据库,以打印控制台代替
System.out.println("查询到了所有的图书类型.......");
return null;
}
}
package com.gychen.demo;
import com.gychen.service.ClassInfoService;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestDemo {
@Test
public void testSpring(){
// 获取spring容器
ClassPathXmlApplicationContext app =
new ClassPathXmlApplicationContext("spring.xml");
// 获取bean
ClassInfoService infoService = (ClassInfoService) app.getBean("classInfoService");
infoService.queryClassInfoAll();
}
}
标签:sch expr 注解 系统 ble package source pat string
原文地址:https://www.cnblogs.com/nuister/p/13361176.html