MaxKeyOpenApiApplication.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.maxkey;
  17. import javax.servlet.ServletException;
  18. import org.joda.time.DateTime;
  19. import org.maxkey.configuration.ApplicationConfig;
  20. import org.maxkey.web.InitializeContext;
  21. import org.mybatis.spring.annotation.MapperScan;
  22. import org.slf4j.Logger;
  23. import org.slf4j.LoggerFactory;
  24. import org.springframework.boot.SpringApplication;
  25. import org.springframework.boot.autoconfigure.SpringBootApplication;
  26. import org.springframework.boot.builder.SpringApplicationBuilder;
  27. import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
  28. import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  29. import org.springframework.context.ConfigurableApplicationContext;
  30. import org.springframework.context.annotation.ComponentScan;
  31. @ComponentScan(basePackages = {
  32. "org.maxkey.authn",
  33. "org.maxkey.configuration",
  34. "org.maxkey.entity",
  35. "org.maxkey.entity.apps",
  36. "org.maxkey.entity.userinfo",
  37. "org.maxkey.web.apis.identity.kafka",
  38. "org.maxkey.web.apis.identity.rest",
  39. "org.maxkey.web.apis.identity.scim",
  40. "org.maxkey.persistence",
  41. "org.maxkey.provision",
  42. "org.maxkey.web",
  43. "org.maxkey.web.api.endpoint",
  44. "org.maxkey.web.contorller",
  45. "org.maxkey.web.endpoint",
  46. "org.maxkey.web.interceptor",
  47. })
  48. @MapperScan("org.maxkey.persistence.mapper,")
  49. @SpringBootApplication
  50. @EnableDiscoveryClient
  51. public class MaxKeyOpenApiApplication extends SpringBootServletInitializer {
  52. private static final Logger _logger = LoggerFactory.getLogger(MaxKeyOpenApiApplication.class);
  53. public static void main(String[] args) {
  54. _logger.info("Start MaxKey OpenApi Application ...");
  55. ConfigurableApplicationContext applicationContext =
  56. SpringApplication.run(MaxKeyOpenApiApplication.class, args);
  57. InitializeContext initWebContext = new InitializeContext(applicationContext);
  58. try {
  59. initWebContext.init(null);
  60. } catch (ServletException e) {
  61. _logger.error("Exception ",e);
  62. }
  63. _logger.info("MaxKey OpenApi at {}" , new DateTime());
  64. _logger.info("MaxKey OpenApi Server Port {}"
  65. ,applicationContext.getBean(ApplicationConfig.class).getPort());
  66. _logger.info("MaxKey OpenApi started.");
  67. }
  68. protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  69. return application.sources(MaxKeyOpenApiApplication.class);
  70. }
  71. }