0
스프링 (Main 클래스 + Bean 클래스)이있는 간단한 독립형 애플리케이션이 있습니다. MBean (JMX)을 작성합니다.Tomcat에 Spring을 배포하는 간단한 애플리케이션
그냥 콩을 시작합니다.
메인 클래스 :
public class Main {
public static void main(final String[] args) {
ApplicationContext ac = new ClassPathXmlApplicationContext("cont.xml");
try {
Thread.sleep(1000 * 60 * 5);
} catch (final Throwable t) {}
}
}
콩
public class Test {
private String val = "";
public String getVal() {
return val;
}
public void setVal(String v) {
val = v;
}
cont.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"
default-lazy-init="true">
<bean id="test" class="test.Test" />
<bean class="org.springframework.jmx.support.MBeanServerFactoryBean">
<property name="locateExistingServerIfPossible" value="true" />
</bean>
<bean class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.MethodNameBasedMBeanInfoAssembler" >
<property name="managedMethods">
<list>
<value>getVal</value>
<value>setVal</value>
</list>
</property>
</bean>
</property>
<property name="beans">
<map>
<entry key="bean:name=Test" value-ref="test"/>
</map>
</property>
</bean>
</beans>
? 감사합니다.
'cont.xml'의 관련 부분을 게시하십시오. Spring이 관리하는'ApplicationContext'와 빈을 어떻게 사용하는지 설명하십시오. 지금은 코드에서 JMX와 Spring 사용을 볼 수 없다. –
완료, 감사합니다! :) –