Создание отдельного веб-клиента и службы отдыха в Spring Boot. Создание двух отдельных приложений. Попытка сделать AJAX-вызов от клиента на http://localhost:8081/
и запустить службу отдыха на http://localhost:8080/someURL/invokeMethod
, которая должна вызвать метод контроллера службы отдыха и выдать LOGGER.info()
на консоль. Когда я запускаю страницу на http://localhost:8081/
, AJAX на клиенте должен выполнить вызов службы, однако я не могу получить выход на консоль из метода контроллера getLogOut()
на контроллере остальной службы.
Rest Service Controller
package com.demo.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/someURL")
public class ServiceController {
private static final Logger LOGGER = LoggerFactory.getLogger(SearchController.class.getName());
@GetMapping("/invokeMethod")
public void getLogOut() {
LOGGER.info("/n/n/n/n/n***************LOGGER IN getLogOut************");
}
}
Веб-клиент index.html:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$.ajax({
url: "http://localhost:8080/someURL/invokeMethod"
});
});
</script>
</head>
<body>
<h1>Load Page to make ajax call</h1>
</body>
</html>
Контроллер веб-клиента:
package com.demo.Web.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping
public class WebController {
private static final Logger LOGGER = LoggerFactory.getLogger(WebController.class.getName());
@GetMapping("/")
public String viewPage() {
LOGGER.info("\n\n\n**********In Index**********");
return "index";
}
}
Не получаю ошибки отконсоль. Просто получить из консоли:
0: 0: 0: 0: 0: 0: 0: 1 - - [06 / Oct / 2019: 21: 21: 28 -0500] "GET /someURL / invokeMethod HTTP / 1.1 "200 722
Не уверен, что выше из консоли пытается сказать мне.
Stacktrace (должно быть завершено)
[INFO]~2019-10-07-09.53.05.313CDT~~~~~~ c.e.h.RestServiceApplication Starting RestServiceApplication on 5CG9107HK6 with PID 162992
[INFO]~2019-10-07-09.53.05.317CDT~~~~~~ c.e.h.RestServiceApplication No active profile set, falling back to default profiles: default
[INFO]~2019-10-07-09.53.05.543CDT~~~~~~ o.s.b.d.e.DevToolsPropertyDefaultsPostProcessor Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
[INFO]~2019-10-07-09.53.05.544CDT~~~~~~ o.s.b.d.e.DevToolsPropertyDefaultsPostProcessor For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
[INFO]~2019-10-07-09.53.06.685CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$6e19173b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.692CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.694CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@cb177' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.701CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$92edb9ed] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.706CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'org.springframework.security.config.annotation.method.configuration.Jsr250MetadataSourceConfiguration' of type [org.springframework.security.config.annotation.method.configuration.Jsr250MetadataSourceConfiguration$$EnhancerBySpringCGLIB$$b842d203] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.707CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'jsr250MethodSecurityMetadataSource' of type [org.springframework.security.access.annotation.Jsr250MethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.708CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.07.074CDT~~~~~~ o.s.b.w.e.t.TomcatWebServer Tomcat initialized with port(s): 8080 (http)
[INFO]~2019-10-07-09.53.07.092CDT~~~~~~ o.a.c.h.Http11NioProtocol Initializing ProtocolHandler ["http-nio-8080"]
[INFO]~2019-10-07-09.53.07.104CDT~~~~~~ o.a.c.c.StandardService Starting service [Tomcat]
[INFO]~2019-10-07-09.53.07.105CDT~~~~~~ o.a.c.core.StandardEngine Starting Servlet engine: [Apache Tomcat/9.0.26]
[INFO]~2019-10-07-09.53.07.225CDT~~~~~~ o.a.c.c.C.[.[.[/] Initializing Spring embedded WebApplicationContext
[INFO]~2019-10-07-09.53.07.225CDT~~~~~~ o.s.w.c.ContextLoader Root WebApplicationContext: initialization completed in 1681 ms
[INFO]~2019-10-07-09.53.07.962CDT~~~~~~ n.r.s.b.l.a.LogbackAccessContext Configured the Logback-access: context=[default], config=[classpath:logback-access.xml]
[INFO]~2019-10-07-09.53.08.093CDT~~~~~~ o.s.s.c.ThreadPoolTaskExecutor Initializing ExecutorService 'applicationTaskExecutor'
[INFO]~2019-10-07-09.53.08.334CDT~~~~~~ o.s.s.w.DefaultSecurityFilterChain Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@1c48ba2, org.springframework.security.web.context.SecurityContextPersistenceFilter@c57134, org.springframework.security.web.header.HeaderWriterFilter@1248239, org.springframework.security.web.csrf.CsrfFilter@183a2cf, org.springframework.security.web.authentication.logout.LogoutFilter@159fde7, com.edwardjones.framework.security.spring.wam.WamAuthenticationFilter@146ee78, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@261552, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@e0f96e, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@300ae4, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@44ff58, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@1de5909, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@15d7b9c, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@df7a4d, org.springframework.security.web.session.SessionManagementFilter@348fee, org.springframework.security.web.access.ExceptionTranslationFilter@13719ad, org.springframework.security.web.access.ExceptionTranslationFilter@b78775, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@1f01a41]
[INFO]~2019-10-07-09.53.08.807CDT~~~~~~ o.s.s.c.ThreadPoolTaskScheduler Initializing ExecutorService 'taskScheduler'
[INFO]~2019-10-07-09.53.08.836CDT~~~~~~ o.s.b.d.a.OptionalLiveReloadServer LiveReload server is running on port 35729
[INFO]~2019-10-07-09.53.08.843CDT~~~~~~ o.s.b.a.e.w.EndpointLinksResolver Exposing 2 endpoint(s) beneath base path '/actuator'
[INFO]~2019-10-07-09.53.08.889CDT~~~~~~ o.a.c.h.Http11NioProtocol Starting ProtocolHandler ["http-nio-8080"]
[INFO]~2019-10-07-09.53.08.996CDT~~~~~~ o.s.b.w.e.t.TomcatWebServer Tomcat started on port(s): 8080 (http) with context path ''
[INFO]~2019-10-07-09.53.09.001CDT~~~~~~ c.e.h.RestServiceApplication Started RestServiceApplication in 3.959 seconds (JVM running for 4.804)
[INFO]~2019-10-07-09.53.39.001CDT~~~~~~ o.a.c.c.C.[.[.[/] Initializing Spring DispatcherServlet 'dispatcherServlet'
[INFO]~2019-10-07-09.53.39.001CDT~~~~~~ o.s.w.s.DispatcherServlet Initializing Servlet 'dispatcherServlet'
[INFO]~2019-10-07-09.53.39.008CDT~~~~~~ o.s.w.s.DispatcherServlet Completed initialization in 7 ms
0:0:0:0:0:0:0:1 - - [07/Oct/2019:09:53:39 -0500] "GET /someURL/invokeMethod HTTP/1.1" 200 722