springboot 自动装配

以下内容部分来自小马哥的 《springboot 编程思想》

基础 springboot 项目

1226359-20190619223442180-1486661678.png

  • maven 依赖
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>2.1.5.RELEASE</version>
            </dependency>
  • 启动

1226359-20190619223709394-2074705907.png

项目会使用默认的8080端口

@SpringBootApplication 注解

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(
    excludeFilters = {@Filter(
    type = FilterType.CUSTOM,
    classes = {TypeExcludeFilter.class}
), @Filter(
    type = FilterType.CUSTOM,
    classes = {AutoConfigurationExcludeFilter.class}
)}
)
public @interface SpringBootApplication {
...
  • 替换@SpringBootApplication
    1226359-20190619224147055-639181391.png

启动成功!

转载于:https://www.cnblogs.com/lanqie/p/11055421.html

猜你喜欢

转载自blog.csdn.net/weixin_33974433/article/details/93878197
今日推荐