springboot中Hello World Application的探究是怎样的

发布时间:2021-09-28 09:27:50 作者:柒染
来源:亿速云 阅读:101

springboot中Hello World Application的探究是怎样的,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

1. POM文件

1. 父项目

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>
    
    spring-boot-starter-parent的父项目:
    <parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-dependencies</artifactId>
		<version>1.5.9.RELEASE</version>
		<relativePath>../../spring-boot-dependencies</relativePath>
	</parent>
	
	spring-boot-dependencies真正来管理Spring Boot项目中所有的依赖版本

Spring Boot的版本仲裁中心,以后我们导入依赖默认不需要写版本(没有在spring-boot-dependencies中的依赖就需要声明版本号)

2. 导入的依赖

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

spring-boot-starter-web :

2. 主程序类,主入口类

/**
 * @SpringBootApplication 来标注一个主程序类,说明这是一个Spring boot应用
 */
@SpringBootApplication
public class HelloWorldMainApplication {

    public static void main(String[] args) {

        //启动Spring应用
        SpringApplication.run(HelloWorldMainApplication.class, args);
    }
}

@SpringBootApplication: Spring Boot应用注解,标注在某个类上说明这是Spring Boot应用的主入口类,SpringBoot就应该运行这个类的main方法来启动应用SpringBoot应用

@SpringBootAppliation

@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 {
    @AliasFor(
        annotation = EnableAutoConfiguration.class,
        attribute = "exclude"
    )
    Class<?>[] exclude() default {};

    @AliasFor(
        annotation = EnableAutoConfiguration.class,
        attribute = "excludeName"
    )
    String[] excludeName() default {};

    @AliasFor(
        annotation = ComponentScan.class,
        attribute = "basePackages"
    )
    String[] scanBasePackages() default {};

    @AliasFor(
        annotation = ComponentScan.class,
        attribute = "basePackageClasses"
    )
    Class<?>[] scanBasePackageClasses() default {};
}

@SpringBootConfiguration

@EnableAutoConfiguration

看完上述内容,你们掌握springboot中Hello World Application的探究是怎样的的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. MPSOC学习之HELLO WORLD
  2. Hello World, Perl

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

springboot hello world application

上一篇:如何安装docker compose

下一篇:Java如何实现垃圾回收机制

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》