Home >Java >javaTutorial >How to apply gradle Plugin in Springboot
Spring Boot’s Gradle plug-in provides Spring Boot’s functional support for the Gradle build tool, which can be used to package projects into executable jars or wars, or to run Spring Boot applications , or use the dependency management provided by spring-boot-dependencies.
You need to add the following configuration to the project to use the plug-in.
// 插件配置 plugins { id 'org.springframework.boot' version '2.4.1' // 使用spring boot id 'io.spring.dependency-management' version '1.0.10.RELEASE' // 使用spring boot的自动依赖管理 id 'java' id 'idea' }
buildscript { repositories { maven { url 'https://maven.aliyun.com/repository/public' } } dependencies { classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.4.1' } } apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'java' apply plugin: 'idea'
Java plugin: It will be automatically packaged into an executable jar during construction. The Java plugin plugin provides a series of Tasks support building, compiling, and testing Java projects.
IDE plug-in: Specify code editing tools (Eclipse, IDEA, etc.)
org.springframework.boot plug-in: Used to execute Spring Boot related Tasks, the bootRun and bootJar tasks we are familiar with all come from this plug-in
io.spring.dependency-management plug-in: The Spring Boot plug-in will automatically download the Spring Boot plug-in you use. Importing the spring-boot-dependencies bom into the Boot version allows you to ignore the version number when declaring dependencies. To use this function, you only need to declare dependencies normally without writing the version number.
The introduction of dependency-management by the Spring boot gradle plug-in will automatically do a core thing: the spring boot gradle plug-in will automatically call dependency-management, and spring-boot-dependencies maintain the spring boot ecosystem. bom data.
As for the difference between the old and new versions, some official built-in plug-ins, such as java, can be introduced directly using plugins, while some third-party libraries, or those who need to specify libraries, can try apply plugin. For detailed differences, please refer to the official document.
The above is the detailed content of How to apply gradle Plugin in Springboot. For more information, please follow other related articles on the PHP Chinese website!