java—如何使用gradle通过netbeans添加maven存储库?

vlurs2pr  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(228)

如何配置 Netbeans 认识到进口包裹的必要性?
无法添加包:

编译失败:

nicholas@mordor:~/NetBeansProjects/chimp$ 
nicholas@mordor:~/NetBeansProjects/chimp$ gradle clean build run 

> Task :compileJava FAILED                                                                                                      
/home/nicholas/NetBeansProjects/chimp/src/main/java/tech/mailchimp/Chimp.java:21: error: cannot find symbol
        MailChimp mailChimp = new MailChimp(new Authentication(user, key), new ProductionCommunicator(), new DataCenterMailChimp("13"));
        ^
  symbol:   class MailChimp
  location: class Chimp
/home/nicholas/NetBeansProjects/chimp/src/main/java/tech/mailchimp/Chimp.java:21: error: cannot find symbol
        MailChimp mailChimp = new MailChimp(new Authentication(user, key), new ProductionCommunicator(), new DataCenterMailChimp("13"));
                                  ^
  symbol:   class MailChimp
  location: class Chimp
/home/nicholas/NetBeansProjects/chimp/src/main/java/tech/mailchimp/Chimp.java:21: error: cannot find symbol
        MailChimp mailChimp = new MailChimp(new Authentication(user, key), new ProductionCommunicator(), new DataCenterMailChimp("13"));
                                                ^
  symbol:   class Authentication
  location: class Chimp
/home/nicholas/NetBeansProjects/chimp/src/main/java/tech/mailchimp/Chimp.java:21: error: cannot find symbol
        MailChimp mailChimp = new MailChimp(new Authentication(user, key), new ProductionCommunicator(), new DataCenterMailChimp("13"));
                                                                               ^
  symbol:   class ProductionCommunicator
  location: class Chimp
/home/nicholas/NetBeansProjects/chimp/src/main/java/tech/mailchimp/Chimp.java:21: error: cannot find symbol
        MailChimp mailChimp = new MailChimp(new Authentication(user, key), new ProductionCommunicator(), new DataCenterMailChimp("13"));
                                                                                                             ^
  symbol:   class DataCenterMailChimp
  location: class Chimp
5 errors

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
2 actionable tasks: 2 executed
nicholas@mordor:~/NetBeansProjects/chimp$

资料来源:

package tech.mailchimp;

import java.util.logging.Logger;

public class Chimp {

    private static final Logger log = Logger.getLogger(Chimp.class.getName());

    public void connect() {

        String key = System.getenv("chimp_key");
        String user = System.getenv("chimp_user");
        String password = System.getenv("chimp_password");
        String server = System.getenv("chimp_server");

        log.fine(key);
        log.fine(user);
        log.fine(password);
        log.fine(server);

        MailChimp mailChimp = new MailChimp(new Authentication(user, key), new ProductionCommunicator(), new DataCenterMailChimp("13"));

        //  ListMailChimp listMailChimp = new ListMailChimp().withEmailTypeOption(true).withName("Test Name").withPermissionReminder("Testing").withCampaignDefault(campaignDefaults).withContact(contact);
        //  listMailChimpToCreated = mailChimp.list().create(listMailChimp);
    }

}

渐变生成文件:

apply plugin: 'java'
apply plugin: 'application'

sourceCompatibility = '1.7'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
    ext.mainClass = 'tech.mailchimp.Chimp'
}

repositories {
    mavenCentral()

    maven { url 'https://jitpack.io' }

    // You may define additional repositories, or even remove "mavenCentral()".
    // Read more about repositories here:
    //   http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}

dependencies {

    implementation 'com.github.NetoDevel:mailchimp-java:0.1.5'

    // TODO: Add dependencies here ...
    // You can read more about how to add dependency here:
    //   http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
    testCompile group: 'junit', name: 'junit', version: '4.10'
}

mainClassName = 'tech.mailchimp.App'

我正在使用ide生成构建文件。
虽然我可以手动添加包,但是 IDE 应该会意识到回购的必要性。
另一种选择是不使用gradle,而是使用不同的自动化工具。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题