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 社群中所有即將舉行的活動。

檢視全部