Idea inside add groovy support for project addition

Source: Internet
Author: User
Tags assert

Groovy is a flexible, dynamic language on the Java platform with features like Python, Ruby and Smalltalk, and groovy guarantees that these features are used by Java developers like Java syntax;

Here's a simple example of groovy dynamics, a feature I've come into contact with and like, groovy
1. In Java, the following JUnit test code executes through

    int method (String arg) {
        return 1;
    }

    int method (Object arg) {
        return 2;
    }

    void Dotest () {
        object o = "Object";
        int result = Method (o);
        Assert.assertequals (2, result); Expected return value is 2 ha
    }

2. In groovy, the following JUnit test code executes

    int method (String arg) {
        return 1
    }

    int method (Object arg) {
        return 2
    }

    void Dotest () { C19/>object o = "Object"
        int result = Method (o)
        assert.assertequals (1, result)//Expected return value is 1 ha
    }

Here's the start of configuring groovy for our project in idea. I use a Web project based on SPRING_MVC to import the project;

There are two ways to add the groovy framework support
Method One: Right-click on the item select "Add Framework support ...", tick groovy, and select the groovy dependency package that was introduced on the right-hand side (you can download the source package from the official webpage to local and unzip it, then configure the introduction here);
Method Two: If the project to be added groovy is based on Maven, it is good to add the required dependencies directly in the Pom file;

<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all< /artifactid>
    <version>2.4.4</version>
</dependency>

Then you can add any groovy code to the project, and for more syntax features of Groovy please refer to: Syntax

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.