我正在编写一个简单的基于 Spring 的 Web 应用程序并将其部署到 Websphere Liberty 8.5.5.9;我已经解决了我的部署问题,并且应用程序似乎开始了(根据 Liberty console.log
)。但是,我没有看到任何控制台或日志输出。我的应用程序主类,其中包含 main 方法中的打印语句,是:
@Configuration
public class UserSettingApplication extends SpringBootServletInitializer implements WebApplicationInitializer {
ServletContext servletContext;
private static final LoggerUtils logger = new LoggerUtils( UserSettingApplication.class );
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
builder.sources(UserSettingApplication.class);
return builder;
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.addListener(RequestContextListener.class);
this.servletContext=servletContext;
super.onStartup(servletContext);
}
public static void main(String[] args) throws Exception {
System.out.println( "Entering UserSettingApplication.main" );
SpringApplicationBuilder applicationBuilder = new UserSettingApplication().configure(new SpringApplicationBuilder());
applicationBuilder.run(args);
System.out.println( "Entering UserSettingApplication.main" );
}
@Override
protected WebApplicationContext run(SpringApplication application) {
WebApplicationContext webApplicationContext = super.run(application);
Environment env = webApplicationContext.getEnvironment();
String sessionName = env.getProperty("server.session.cookie.name", "xplore-session-id");
servletContext.getSessionCookieConfig().setName(sessionName);
return webApplicationContext;
}
@Bean
protected RequestContextListener requestContextListener() {
return new RequestContextListener();
}
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> {
logger.info("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
logger.info(beanName);
}
};
}
}
我不应该在 WASLiberty 的 main 方法中看到 print 语句console.log
吗?