我正在尝试使用 Spring Boot 设置一个简单的 Web CRUD 应用程序。我知道我应该是 spring boot servelet 初始值设定项,但是在日志中,我怀疑它没有正常运行,因为它没有记录我写的内容。
最终目标是让我能够访问http://localhost:8080/LNU-Project/和 home.jsp 显示。
这是 github 上的链接。https://github.com/rjpruitt16/LNU-Project/tree/master/src/main
WebAppInitializer.java
package com.project.LNUProject;
import com.project.LNUProject.config.WebConfig; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.servlet.DispatcherServlet;
import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRegistration;
@Slf4j
@SpringBootApplication
public class WebAppInitializer extends SpringBootServletInitializer {
private static final String DISPATCHER_SERVLET_NAME = "dispatcher";
public static void main(String[] args) {
SpringApplication.run(WebAppInitializer.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebAppInitializer.class);
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
log.info("onStartUp");
// create the spring application context
AnnotationConfigWebApplicationContext context =
new AnnotationConfigWebApplicationContext();
context.register(WebConfig.class);
// create the dispatcher servlet
DispatcherServlet dispatcherServlet =
} }
慕神8447489
阿波罗的战车
相关分类