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)

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

获取 Spring 新闻简报

保持与 Spring 新闻简报的联系

订阅

抢先一步

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

了解更多

获取支持

Tanzu Spring 在一个简单的订阅中提供对 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件。

了解更多

即将举行的活动

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

查看全部