Home > Java > javaTutorial > body text

How to apply gradle Plugin in Springboot

王林
Release: 2023-05-11 20:25:14
forward
1721 people have browsed it

Springboot application gradle Plugin detailed explanation

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.

New version

// 插件配置
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'
}
Copy after login

Old version

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'
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!