Spring Boot 0.5.0.M5 发布

版本发布 | Dave Syer | 2013年10月09日 | ...

Spring Boot 0.5.0.M5 可在 Spring 仓库 中获取。安装和使用说明请参见 项目网站GitHub。包含大量新功能,包括:

  • 对 JMS、AMQP、AOP、Mobile、MongoDB 的自动配置支持
  • 简化的 @Grab 用法(见下面的示例)
  • 一个用于 Groovy 脚本的测试命令(支持 JUnit 和 Spock,更多细节将在 Greg 的博客中介绍)
  • 新的 SpringApplicationBuilder,支持应用程序上下文层次结构等
  • 新的 PropertiesLauncher,可以从运行时发现的属性启动 Java 应用程序(例如,从 lib 目录设置类路径)

作为一名品鉴者,这里有一个在 Java 中使用 SpringApplicationBuilder 构建带有父上下文的应用程序的示例用法(如果您想从同一代码运行多个应用程序,这将非常有用)

@Configuration
@EnableAutoConfiguration
public class Server {

	public static void main(String[] args) {
		new SpringApplicationBuilder(Parent.class)
                    .child(Server.class)
                    .profiles("server")
                    .run(args);
	}

        // ... @Bean definitions follow
}

上面的 Parent.class 是一个共享的父上下文,可以在同一模块中的其他应用程序重复使用。

下面是一个 Groovy 应用程序中缩写的 @Grab 的示例(组和版本信息会自动添加)

@Grab("spring-boot-starter-actuator")
@RestController
class Example {

	@RequestMapping("/")
	String home() {
		[message: 'Hello World']
	}
}

此应用程序独立运行,例如,如果您使用 spring shell 脚本启动它,它将在当前目录中运行

$ spring run app.groovy
... (app starts up)

在浏览器中访问 https://:8080/,然后尝试访问 https://:8080/metrics

获取 Spring 新闻通讯

通过 Spring 新闻通讯保持联系

订阅

领先一步

VMware 提供培训和认证,助您加速进步。

了解更多

获得支持

Tanzu Spring 提供 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件,只需一份简单的订阅。

了解更多

即将举行的活动

查看 Spring 社区所有即将举行的活动。

查看所有