SpringBoot学习--介绍、特点、入门程序

1,SpringBoot介绍

  • 随着动态语言的流行(Ruby,Groovy,Scala,Node.js),Java的开发显得格外笨重:繁多的配置、低下的开发效率、复杂的部署流程以及第三方技术集成难度大
  • 在上述环境下,SpringBoot应运而生。它使用“习惯由于配置”的理念让项目快速运行起来。使用springboot很容易创建一个独立运行(运行jar,内嵌Servlet容器)准生产级别的基于Spring框架的项目,使用SpringBoot可以不用或只需要很少的配置。

2,SpringBoot核心特点

  • 可以以jar包的形式独立运行
  • 内嵌Servlet容器,springboot可以选择Tomcat,Jetty或者Undertow,这样我们无须以war包形式部署项目
  • SpringBoot提供了基于http,ssh,Telnet对运行时的项目进行监控

3,入门程序

  • 创建maven项目
    在这里插入图片描述

修改pom.xml

<!-- 父级依赖 -->
  <parent>
  		<groupId>org.springframework.boot</groupId>
  		<artifactId>spring-boot-starter-parent</artifactId>
  		<version>1.5.9.RELEASE</version>
  </parent>
  <!-- 使用springmvc和spring的jar包 -->
  <dependencies>
  		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
  </dependencies>
  
  <build>
  		<plugins>
  			<plugin>
  				<groupId>org.apache.maven.plugins</groupId>
  				<artifactId>maven-compiler-plugin</artifactId>
  				<configuration>
  					<source>1.8</source>
  					<target>1.8</target>
  				</configuration>
  			</plugin>
  		</plugins>
  </build>

controller

//exclude= {RedisAutoConfiguration.class} 关闭某一项自动配置
@EnableAutoConfiguration(exclude= {RedisAutoConfiguration.class})  //启用自动配置
@Controller
public class TestController {
	
	@RequestMapping("/hello")
	@ResponseBody
	public String requestHello() {
		return "hello";
	}
	
	//入口
	public static void main(String[] args) {
		SpringApplication.run(TestController.class, args);
	}
}

猜你喜欢

转载自blog.csdn.net/yzx15855401351/article/details/83118590
今日推荐