MaxKeyApplication.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 java.util.Date;
  18. import javax.servlet.ServletException;
  19. import org.apache.ibatis.io.VFS;
  20. import org.apache.mybatis.jpa.SpringBootVFS;
  21. import org.maxkey.configuration.ApplicationConfig;
  22. import org.maxkey.web.InitializeContext;
  23. import org.mybatis.spring.annotation.MapperScan;
  24. import org.slf4j.Logger;
  25. import org.slf4j.LoggerFactory;
  26. import org.springframework.boot.SpringApplication;
  27. import org.springframework.boot.autoconfigure.SpringBootApplication;
  28. import org.springframework.boot.builder.SpringApplicationBuilder;
  29. import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
  30. import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  31. import org.springframework.context.ConfigurableApplicationContext;
  32. @SpringBootApplication
  33. @EnableDiscoveryClient
  34. @MapperScan("org.maxkey.persistence.mapper,")
  35. public class MaxKeyApplication extends SpringBootServletInitializer {
  36. private static final Logger _logger = LoggerFactory.getLogger(MaxKeyApplication.class);
  37. /**
  38. * @param args start parameter
  39. */
  40. public static void main(String[] args) {
  41. _logger.info("Start MaxKeyApplication ...");
  42. VFS.addImplClass(SpringBootVFS.class);
  43. ConfigurableApplicationContext applicationContext =
  44. SpringApplication.run(MaxKeyApplication.class, args);
  45. InitializeContext initWebContext = new InitializeContext(applicationContext);
  46. try {
  47. initWebContext.init(null);
  48. } catch (ServletException e) {
  49. _logger.error("ServletException", e);
  50. }
  51. _logger.info("MaxKey at " + new Date(applicationContext.getStartupDate()));
  52. _logger.info("MaxKey Server Port "
  53. + applicationContext.getBean(ApplicationConfig.class).getPort());
  54. _logger.info("MaxKey started.");
  55. }
  56. protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  57. return application.sources(MaxKeyApplication.class);
  58. }
  59. }