Я добавил библиотеку с этой зависимостью
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
, тогда, когда я пытаюсь создать класс pojo, Idea сказала мне, что он не может найти класс, но класс существует java.lang.ClassNotFoundException: org.codehaus.jackson.annotate.JsonUnwrapped
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.addHeader("Content-Type", "application/json; charset=utf-8");
StringBuilder builder = new StringBuilder();
String a = null;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(req.getInputStream(), "UTF-8"))){
while ((a = reader.readLine())!=null){
builder.append(a);
}
}
ObjectMapper objectMapper = new ObjectMapper();
UserPojo pojo = objectMapper.readValue(builder.toString(),UserPojo.class);
}
Пример изображения:
I have this library in classpath.
And I try to use another version of jackson. When I use version 2.+ I have another crazy error Idea can't find class ObjectMapper only in this class.
On this picture i have class (ObjectMapper) not found error:
On this picture I DON'T have error:
but this two class in one package. How it's possible and How it's fix?
Add pom
<?xml version="1.0" encoding="UTF-8"?>
4.0.0 PetClinic cpw 1.0-SNAPSHOT война Клиника Pet Web http://maven.apache.org org.hibernate hibernate-core 5.3.5. Финал postgresql postgresql 9.1-901-1.jdbc4 org.codehaus.jackson jackson-core-asl 1.9.13 org.codehaus.jackson jackson-mapper-asl 1.9.13 log4j log4j 1.2.17 jstl jstl 1.2 javax.servlet servlet-api 2,5 при условии регистрация общего пользования регистрация общего пользования 1.1.1 taglibs стандарт 1.1.2 commons-lang commons-lang 2.1 org.codehaus.plexus plexus-utils 1.1 junit junit 4.8.2 тест PetClinic se 1.0-SNAPSHOT org.mockito mockito-all 1.10.19 test PetClinicWeb org.apache.maven.plugins maven-compiler-plugin 3.3 1.7 1.7 UTF-8 org.jacoco jacoco-maven-plugin 0.7.4.201502262128 $ {basedir} /target/coverage-reports/jacoco-unit.exec $ {basedir} /target/coverage-reports/jacoco-unit.exec jacoco-initialize prepare-agent jacoco-site пакет отчет