相关疑难解决方法(0)

Gradle中的实现和编译之间有什么区别?

在更新到Android Studio 3.0并创建一个新项目后,我注意到build.gradle有一种新方法可以添加新的依赖项,而不是compile存在implementation而不是testCompile存在testImplementation.

例:

 implementation 'com.android.support:appcompat-v7:25.0.0'
 testImplementation 'junit:junit:4.12'
Run Code Online (Sandbox Code Playgroud)

代替

 compile 'com.android.support:appcompat-v7:25.0.0'
 testCompile 'junit:junit:4.12'
Run Code Online (Sandbox Code Playgroud)

它们之间有什么区别,我应该使用什么?

dependency-management gradle transitive-dependency build.gradle gradle-plugin

899
推荐指数
10
解决办法
27万
查看次数

如何在Java 9中解决java.lang.NoClassDefFoundError:javax/xml/bind/JAXBException

我有一些代码使用JAXB API类,它们是作为Java 6/7/8中JDK的一部分提供的.当我使用Java 9运行相同的代码时,在运行时我得到错误,指示无法找到JAXB类.

自Java 6以来,JAXB类已作为JDK的一部分提供,为什么Java 9不再能够找到这些类?

java jaxb java-9 java-10 java-11

718
推荐指数
27
解决办法
46万
查看次数

程序可以在编译期间依赖于库而不是运行时吗?

我理解运行时和编译时之间的区别以及如何区分这两者,但我没有看到需要区分编译时和运行时依赖.

我正在窒息的是:程序如何在编译期间不依赖运行时依赖的东西?如果我的Java应用程序使用log4j,那么它需要log4j.jar文件才能编译(我的代码集成并调用log4j内部的成员方法)以及运行时(我的代码完全无法控制log4j中的代码后发生的事情) .jar跑了).

我正在阅读依赖解析工具,如Ivy和Maven,这些工具清楚地区分了这两种类型的依赖关系.我只是不明白它的必要性.

任何人都可以给出一个简单的,"国王的英语"式的解释,最好有一个实际的例子,即使像我这样的可怜的人也能理解?

java build-process runtime compile-time

106
推荐指数
5
解决办法
5万
查看次数

杰克逊无法访问com.fasterxml.jackson.core.ObjectCodec

这个问题是一个跟进到这一个.我似乎无法在以下代码中访问jackson库:

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.ObjectWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class ServerConfiguration {
    public String info = null;
    public String idlURL = null;
    public String idlContents = null;
    public List<ServerInfo> servers = new ArrayList<>();

    public final void clear() {
        info = null;
        idlURL = null;
        idlContents = null;
        if (servers != null)
            servers.clear();
    }

    private final static ObjectReader jsonReader;
    private final static ObjectWriter jsonWriter;

    static {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, …
Run Code Online (Sandbox Code Playgroud)

java json intellij-idea jackson maven

16
推荐指数
3
解决办法
2万
查看次数

Maven Jetty垃圾邮件警告“从多个位置扫描”

我在这里找到了类似的问题,但是它指向的是我没有使用(maven-failsafe-plugin)的插件,解决方案所指的配置不适用于我。

问题是,因为我已经更新了我的码头插件

<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.9.v20160517</version>
Run Code Online (Sandbox Code Playgroud)

<version>9.4.11.v20180605</version>,它开始向数百个警告发送垃圾邮件,例如

[WARNING] org.apache.axis2.description.java2wsdl.bytecode.ClassReader scanned from multiple locations: jar:file:///C:/Users/a0763323/.m2/repository/org/apache/axis2/axis2-kernel/1.4.1/axis2-kernel-1.4.1.jar!/org/apache/axis2/description/java2wsdl/bytecode/ClassReader.class, jar:file:///C:/Users/a0763323/.m2/repository/it/aon/WSInfocar/1.2/WSInfocar-1.2.jar!/org/apache/axis2/description/java2wsdl/bytecode/ClassReader.class
[WARNING] org.apache.axis2.description.java2wsdl.bytecode.MethodTable scanned from multiple locations: jar:file:///C:/Users/a0763323/.m2/repository/org/apache/axis2/axis2-kernel/1.4.1/axis2-kernel-1.4.1.jar!/org/apache/axis2/description/java2wsdl/bytecode/MethodTable.class, jar:file:///C:/Users/a0763323/.m2/repository/it/aon/WSInfocar/1.2/WSInfocar-1.2.jar!/org/apache/axis2/description/java2wsdl/bytecode/MethodTable.class
[WARNING] org.apache.axis2.description.java2wsdl.bytecode.ParamNameExtractor scanned from multiple locations: jar:file:///C:/Users/a0763323/.m2/repository/org/apache/axis2/axis2-kernel/1.4.1/axis2-kernel-1.4.1
Run Code Online (Sandbox Code Playgroud)

我到处搜索过,但是我既不明白这意味着什么也不知道如何解决。

我正在使用IntelliJ和Maven编译器插件

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
Run Code Online (Sandbox Code Playgroud)

谢谢

java jetty maven

9
推荐指数
1
解决办法
3953
查看次数

如何从具有相同结构的不同jar中解析我的类

如何从具有相同结构的不同jar中解析我的类

注意:虽然有问题的罐子中含有这个词,但这里的问题与没有直接关系

直到几天前,PhantomJSDriver一起发布了selenium-server-standalone-v.v.v.jar.所以我的班级工作正常:

import java.io.File;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;

public class A_PhantomJS
{
    public static void main(String[] args) 
    {
          File path=new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
          System.setProperty("phantomjs.binary.path",path.getAbsolutePath());
          WebDriver driver= new PhantomJSDriver();
          driver.manage().window().maximize();
          driver.get("https://www.google.co.in");
    }
}
Run Code Online (Sandbox Code Playgroud)

现在selenium-server-standalone-v.v.v.jar不会将jar 包装PhantomJSDriver依赖项.

所以我已经下载了jar phantomjsdriver-1.1.0.jar并将其作为外部jar添加到我的项目中.

您可以看到它的结构phantomjsdriver-1.1.0.jar与捆绑时的结构类似selenium-server-standalone-v.v.v.jar

PhantomJSDriver

现在,虽然我的班级通过以下方式解决:

import org.openqa.selenium.phantomjs.PhantomJSDriver;
Run Code Online (Sandbox Code Playgroud)

但我面临java.lang.NoClassDefFoundError如下运行时异常:

Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/browserlaunchers/Proxies
    at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:178)
    at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
    at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:89)
    at demo.A_PhantomJS.main(A_PhantomJS.java:15)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.browserlaunchers.Proxies
    at java.net.URLClassLoader.findClass(Unknown …
Run Code Online (Sandbox Code Playgroud)

java selenium jar classnotfoundexception phantomjs

7
推荐指数
1
解决办法
730
查看次数

使用 kafka 连接器运行 flink 时出现 NoClassDefFoundError

我正在尝试使用 flink 从 kafka 流式传输数据。我的代码编译没有错误,但在运行时出现以下错误:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: 
    org/apache/flink/streaming/util/serialization/DeserializationSchema
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.streaming.util.serialization.DeserializationSchema
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more  
Run Code Online (Sandbox Code Playgroud)

我的POM依赖列表如下:

    <dependencies>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-java</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-streaming-core</artifactId>
            <version>0.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-clients</artifactId>
            <version>0.10.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-connector-kafka-0.9_2.11</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version> …
Run Code Online (Sandbox Code Playgroud)

java apache-flink flink-streaming

5
推荐指数
1
解决办法
2万
查看次数