我是初学者使用Spring。对于传入日志文件的消息处理,我只需要一个简单的网关/ web服务器应用程序。 (没有gui)
我使用Spring MVC来实现一个简单的客户端 - 服务器应用程序。执行此程序会导致常见的404 NOT FOUND错误:
11:33:45.674 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor'
11:33:45.674 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor'
11:33:45.676 [main] DEBUG o.s.c.s.ClassPathXmlApplicationContext - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor@7490b4d0]
11:33:45.676 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor'
11:33:45.678 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.liveBeansView.mbeanDomain' in [systemProperties]
11:33:45.679 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.liveBeansView.mbeanDomain' in [systemEnvironment]
11:33:45.679 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'spring.liveBeansView.mbeanDomain' in any property source. Returning [null]
11:33:45.679 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'DLMClient'
11:33:45.699 [main] DEBUG o.s.web.client.RestTemplate - Created GET request for "http://localhost:8000/api/rawData/test"
11:33:45.772 [main] DEBUG o.s.web.client.RestTemplate - Setting request Accept header to [application/json, application/*+json]
11:33:45.792 [main] WARN o.s.web.client.RestTemplate - GET request for "http://localhost:8000/api/rawData/test" resulted in 404 (Not Found); invoking error handler
Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 404 Not Found
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
我使用以下主要参数定义了我的客户端xml:
<bean id="serverConfig" class=".....service.client.ServerConfig">
<property name="host" value="localhost"/>
<property name="port" value="8000"/>
</bean>
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate"/>
</beans>
我的服务器xml使用以下主要参数指定:
<?xml version="1.0" encoding="UTF-8"?>
<bean id="rmiServiceExporter"
class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="dlmService" value="DLMServerService"/>
<property name="service" ref="localhost"/>
<property name="registryPort" value="8000"/>
</bean>
我正在执行以下课程:
public static void main(String[] args) {
final ApplicationContext applicationContext =
new ClassPathXmlApplicationContext("/clientContext.xml", Driver.class);
final DLMClient client = applicationContext.getBean(DLMClient.class);
client.execute("test");
}
DLMClient类包含此方法:
/**
* @param name
*/
public void execute(String name) {
final DLMRestClient hello = getForObject("/api/rawData/{name}",
DLMRestClient.class, name);
System.out.println(hello.getId());
}
由于我不需要任何GUI,因此我没有带有更多xml和jsp文件的WEB-INF文件夹。任何想法,我必须做什么?缺少哪些部分或其他工具的建议只是实现一个简单的网关来安排日志消息?
由于