CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2021-05-16
by copbint

Original Post

Original - Posted on 2016-07-14
by Wilder Valera



            
Present in both answers; Present only in the new answer; Present only in the old answer;

add jackson-databind in pom.xml solved my problem: ```xml <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.12.1</version> </dependency> ```
Add this <i>Bean</i> in your webconfig class
@Bean public ContentNegotiatingViewResolver contentViewResolver() { ContentNegotiationManagerFactoryBean contentNegotiationManager = new ContentNegotiationManagerFactoryBean(); contentNegotiationManager.addMediaType("json", MediaType.APPLICATION_JSON);
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); viewResolver.setPrefix("/WEB-INF/jsp/"); viewResolver.setSuffix(".jsp");
MappingJackson2JsonView defaultView = new MappingJackson2JsonView(); defaultView.setExtractValueFromSingleKeyModel(true);
ContentNegotiatingViewResolver contentViewResolver = new ContentNegotiatingViewResolver(); contentViewResolver.setContentNegotiationManager(contentNegotiationManager.getObject()); contentViewResolver.setViewResolvers(Arrays.<ViewResolver> asList(viewResolver)); contentViewResolver.setDefaultViews(Arrays.<View> asList(defaultView)); return contentViewResolver; }
**UPDATE**
The guys from the comments are right, this won't fix your issue but I noticed something.
If I set consumes = MediaType.APPLICATION_JSON_VALUE and in the request I don't specify the content type it will throw an exception then if I set the content type the issue is fixed.
Now, the issue seems to be something with your dependencies.
My pom dependencies:
<properties> <springframework.version>4.1.9.RELEASE</springframework.version> <springframework.security.oauth.version>2.0.9.RELEASE</springframework.security.oauth.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
...
</properties>
<dependencies>
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${springframework.version}</version> </dependency>
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${springframework.version}</version> </dependency>
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${springframework.version}</version> </dependency>
<dependency> <groupId>org.springframework.security.oauth</groupId> <artifactId>spring-security-oauth2</artifactId> <version>${springframework.security.oauth.version}</version> </dependency>
<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.3.1</version> </dependency>
...
</dependencies>

        
Present in both answers; Present only in the new answer; Present only in the old answer;