티스토리 뷰
HelloWorldService
package egovframework.guide.helloworld;
public interface HelloWorldService {
public String sayHello();
}
public interface HelloWorldService {
public String sayHello();
}
HelloWorldServiceImpl
package egovframework.guide.helloworld;
public class HelloWorldServiceImpl implements HelloWorldService{
private String name;
public void setName(String name) {
this.name = name;
}
public String sayHello() {
return "Hello " + name + "!!!" ;
}
}
public class HelloWorldServiceImpl implements HelloWorldService{
private String name;
public void setName(String name) {
this.name = name;
}
public String sayHello() {
return "Hello " + name + "!!!" ;
}
}
common-servlet.xml : helloworld를 name 속성으로 서비스 구현클래스를 정의하고 있으며 해당 서비스의 name 속성을 “egov framework”로 선언하였다.
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:annotation-config/>
<bean name="helloworld" class="egovframework.guide.helloworld.HelloWorldServiceImpl">
<property name="name">
<value>egov framework</value>
</property>
</bean>
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:annotation-config/>
<bean name="helloworld" class="egovframework.guide.helloworld.HelloWorldServiceImpl">
<property name="name">
<value>egov framework</value>
</property>
</bean>
</beans>
HelloWorld 서비스를 실행하기 위한 클라이언트 클래스
package egovframework.guide.helloworld;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class HelloWorldClient {
private static Log logger = LogFactory.getLog(HelloWorldClient.class);
/**
* @param args
*/
public static void main(String[] args) {
String configLocation = "context-helloworld.xml";
ApplicationContext context = new ClassPathXmlApplicationContext(configLocation);
HelloWorldService helloworld = (HelloWorldSer-vice)context.getBean("helloworld");
logger.debug(helloworld.sayHello());
}
}
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class HelloWorldClient {
private static Log logger = LogFactory.getLog(HelloWorldClient.class);
/**
* @param args
*/
public static void main(String[] args) {
String configLocation = "context-helloworld.xml";
ApplicationContext context = new ClassPathXmlApplicationContext(configLocation);
HelloWorldService helloworld = (HelloWorldSer-vice)context.getBean("helloworld");
logger.debug(helloworld.sayHello());
}
}
'JAVA' 카테고리의 다른 글
redirect / forward [update, delete, insert] (0) | 2017.07.23 |
---|---|
설치 파일과 java파일이 맞지 않는다? 일시적 오류... (0) | 2017.07.22 |
[전자정부프레임워크] 프로젝트 생성 (0) | 2017.07.21 |
[전자정부프레임워크] 페이징 커스터마이징 (0) | 2017.07.21 |
페이지네이션 스킨 두개 만들기 (0) | 2017.07.21 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 터미널
- floating button
- jstree
- server.xml
- input
- 오라클
- 위잇딜라이트
- Mac
- Eclipse
- html
- 메뉴관리
- 성수밥
- 아파치
- 성수뚝떡
- Apach
- SQL
- 톰캣
- 이클립스
- 토라식당
- Oracle
- 조직도관리
- 맥
- Tomcat
- 정규식
- tree로만들기
- 힘냉면록
- Lalavel
- 르프리크
- node관리
- 최고심
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
글 보관함
반응형