2017-12-19 1 views
0

내 프로젝트가 일식 산소와 화성에서 한 번 열렸는데 일식 산소 (일식 제안)에서 jackson lib를 가져올 수있는 수정 사항이 표시되었습니다. 비록 내가 이미 내 프로젝트의 내 gradle 의존성 목록에 같은 의존성을 언급했지만.jackson lib gradle의 이클립스 클래스 경로 문제

이클립스 화성에서 같은 프로젝트를 열었고 종속성이 빌드 경로 (deps 목록)에 표시되고 내 gradle deps 목록에 있지만 이클립스 화성은 여전히 ​​소스 코드에 오류를 표시하고 있습니다.

프로젝트를 정리하고 ./gradlew eclipse도했는데 모든 것이 성공적이지만 이클립스 화성은 종속성을 해결하지 못합니다. 어떻게이 문제를 해결해야합니까?

내 build.gradle는

/* 
* This build file was generated by the Gradle 'init' task. 
* 
* This generated file contains a sample Java Library project to get you started. 
* For more details take a look at the Java Libraries chapter in the Gradle 
* user guide available at https://docs.gradle.org/3.5/userguide/java_library_plugin.html 
*/ 

// Apply the java-library plugin to add support for Java Library 
apply plugin: 'java-library' 
apply plugin: 'eclipse' 

// In this section you declare where to find the dependencies of your project 
repositories { 
    // Use jcenter for resolving your dependencies. 
    // You can declare any Maven/Ivy/file repository here. 
    jcenter() 
    mavenCentral() 
} 

dependencies { 
    // This dependency is exported to consumers, that is to say found on their compile classpath. 
    api 'org.apache.commons:commons-math3:3.6.1' 

    // This dependency is used internally, and not exposed to consumers on their own compile classpath. 
    implementation 'com.google.guava:guava:21.0' 

    // Use JUnit test framework 
    testImplementation 'junit:junit:4.12' 

    // https://mvnrepository.com/artifact/org.jsoup/jsoup 
    compile group: 'org.jsoup', name: 'jsoup', version: '1.11.2' 

    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core 
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.3' 


} 

enter image description here

여기 심판에 대한 내 코드입니다 당신이 잭슨 코어의 일부가 아닌 클래스를 사용하고

import java.io.File; 
import java.io.IOException; 
import java.net.URL; 
import java.util.Iterator; 
import java.util.Scanner; 
import java.util.regex.Pattern; 

import org.jsoup.Jsoup; 
import org.jsoup.nodes.Document; 
import org.jsoup.nodes.Element; 
import org.jsoup.select.Elements; 

import com.fasterxml.jackson.core.JsonProcessingException; 
import com.fasterxml.jackson.databind.ObjectMapper; 
import com.fasterxml.jackson.databind.node.ArrayNode; 
import com.fasterxml.jackson.databind.node.ObjectNode; 

public class Main { 

// public ObjectMapper mapper = new ObjectMapper(); 

    public static void main(String[] args) { 
//  for (String html : args) { 
//   Main main = new Main(); 
//   try { 
//    main.parseHtml(html); 
//   } catch (JsonProcessingException e) { 
//    e.printStackTrace(); 
//   } 
//  } 

     Main main = new Main(); 

     String html = main.getFile("appleInc.html"); 
     try { 
      main.parseHtml(html); 
     } catch (JsonProcessingException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
    } 

    private String getFile(String fileName) { 

     StringBuilder result = new StringBuilder(""); 

     //Get file from resources folder 
     ClassLoader classLoader = getClass().getClassLoader(); 
     File file = new File(classLoader.getResource(fileName).getFile()); 

     try (Scanner scanner = new Scanner(file)) { 

      while (scanner.hasNextLine()) { 
       String line = scanner.nextLine(); 
       result.append(line).append("\n"); 
      } 

      scanner.close(); 

     } catch (IOException e) { 
      e.printStackTrace(); 
     } 

     return result.toString(); 

     } 

    public void parseHtml(String html) throws JsonProcessingException { 
     Document document = Jsoup.parse(html); 
     // parse all the table required 
//  ArrayNode tableInfo = retrieveTableInfo(document); 

     // get the metadata from the html 
     ObjectNode metadataObject = retrieveMetadataInfo(document); 
//  tableInfo.add(metadataObject); 
//  System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(tableInfo)); 
    } 

    @SuppressWarnings("unused") 
    private ObjectNode retrieveMetadataInfo(Document document) { 
     String type = document.getElementsByTag("type").text(); 
     String companyName = findCompanyName(document); 
     String employerIdentificationNo = findEmployerIdentificationNumber(document); 
     return null; 
    } 

    private String findEmployerIdentificationNumber(Document document) { 
     String employerNo = ""; 
     employerNo = document.getElementsContainingText("I.R.S. Employer").prev("div").text(); 
     if (employerNo.isEmpty()) { 
      Iterator<Element> iterator = document.getElementsContainingText("Employer Identification").prev("tr") 
        .iterator(); 
      while (iterator.hasNext()) { 
       Element element = (Element) iterator.next(); 
       if (element.is("tr")) { 
        employerNo = element.getElementsMatchingText(getPattern()).text(); 
       } 
      } 
     } 
     return null; 
    } 

    private Pattern getPattern() { 
     String re1 = "(\\d+)"; 
     String re2 = "(-)"; 
     String re3 = "(\\d+)"; 

     return Pattern.compile(re1 + re2 + re3, Pattern.CASE_INSENSITIVE | Pattern.DOTALL); 
    } 

    private String findCompanyName(Document document) { 
     return document.getElementsContainingText("Exact name of Registrant").prev("div").text(); 
    } 

    private ArrayNode retrieveTableInfo(Document document) { 
     Elements tables = document.getElementsByTag("table"); 
     tables.forEach(table -> { 
      if (Validator.isTableUsefull(table)) 
       return; 
      String tableTitle = getTableTitle(document, table); 

     }); 

     return null; 
    } 

    private String getTableTitle(Document document, Element table) { 
     // TODO Auto-generated method stub 
     return null; 
    } 
} 

enter image description here

+0

스크린 샷은 라이브러리가 해결되었음을 보여줍니다 .. 올바르게 이해하면 컴파일 오류가 발생합니다. 코드 란 무엇이며 오류는 무엇입니까? –

+0

그 해결책을 찾으면 왜 나는 소스 코드에서 컴파일 오류가 발생합니까? - 이클립스 화성? –

+0

코드가 무엇인지, 오류가 무엇인지 알면 그 질문에 대답 할 수있는 기회가 훨씬 더 많습니다. 그러나 당신은 분명히 (현재 두 번) 질문을 받았음에도 불구하고 그것을 게시하는 것을 거부합니다. 그래서 투표를 끝내겠다. –

답변

2

. the documentation을 탐색하거나 jar 파일의 내용을 살펴보면 알 수 있습니다.

알다시피, com.fasterxml.jackson.core 클래스의 JsonProcessingException 클래스는 문제없이 발견됩니다. 은 잭슨 코어의 부분이기 때문입니다.

누락 된 클래스는 모두 com.fasterxml.jackson.databind 패키지에 있습니다. 문제를 해결하려면 필요한 라이브러리 인 com.fasterxml.jackson.core:jackson-databind을 추가해야합니다.

+0

고맙습니다 - 내가 얼마나 바보인지 - 이클립스 산소에서는 이처럼 컴파일 오류가 발생하지 않았기 때문에이 세부 정보를 볼 수 없었습니다. 고맙습니다. 감사합니다. –