|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com;
|
|
|
|
|
package com; // 定义包名为com,表示该文件位于com包下
|
|
|
|
|
|
|
|
|
|
// 导入Spring Boot和MyBatis相关的注解和类
|
|
|
|
|
import org.mybatis.spring.annotation.MapperScan;
|
|
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
|
@ -7,17 +8,19 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
|
|
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
|
|
|
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
|
|
|
|
|
|
|
|
|
@SpringBootApplication
|
|
|
|
|
@ServletComponentScan(value = "com.ServletContextListener")
|
|
|
|
|
@MapperScan(basePackages = {"com.dao"})
|
|
|
|
|
public class jianshenfangglApplication extends SpringBootServletInitializer{
|
|
|
|
|
@SpringBootApplication // 标识这是一个Spring Boot应用程序的主类,包含自动配置、组件扫描等功能
|
|
|
|
|
@ServletComponentScan(value = "com.ServletContextListener") // 指定扫描Servlet组件的包路径,用于注册Servlet、Filter等
|
|
|
|
|
@MapperScan(basePackages = {"com.dao"}) // 指定MyBatis的Mapper接口所在的包路径,Spring会自动扫描并注册这些接口
|
|
|
|
|
public class jianshenfangglApplication extends SpringBootServletInitializer { // 主类继承SpringBootServletInitializer,支持以WAR包形式部署
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
// 主方法,启动Spring Boot应用程序
|
|
|
|
|
SpringApplication.run(jianshenfangglApplication.class, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) {
|
|
|
|
|
return applicationBuilder.sources(jianshenfangglApplication.class);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) {
|
|
|
|
|
// 重写configure方法,用于配置Spring Boot应用程序的启动源,支持外部容器(如Tomcat)部署
|
|
|
|
|
return applicationBuilder.sources(jianshenfangglApplication.class);
|
|
|
|
|
}
|
|
|
|
|
}
|