I m following a spring boot example from a tutorial wich implement a Restful service to get the list of persons from Database table , but I m getting an error when I call : http://localhost:8080/person on IE : No converter found for return value of type: class java.util.ArrayList . So far I tried to add Jackson dependencies from a suggestion on stackoverflow , following my classes, any help is appreciated . SpringbootApplication :
package ben;
@SpringBootApplication
@EnableAutoConfiguration
public class SpringBootWebApplication
{
public static void main (String [] args) {
SpringApplication.run(SpringBootWebApplication.class, args);
}
}
BDE4 class:
package ben.models;
@Entity
@Table(name="BDE4")
public class Bde
{
@Id
@Column
private int id;
@Column
private int numero;
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public int getNumero()
{
return numero;
}
public void setNumero(int numero)
{
this.numero = numero;
}
}
PrsonRepository interface:
package ben.repository;
@Repository
public interface PersonRepository extends CrudRepository<Bde, Integer> {
}
PersonService interface :
package ben.services;
public interface PersonService
{
public List <Bde> findAll();
}
PersonServiceImpl Class:
package ben.services;
@Service
public class PersonServiceImpl implements PersonService
{
@Autowired
private PersonRepository personRepository;
@Override
public List<Bde> findAll()
{
System.out.println("PersonServiceImpl");
return (List<Bde>) personRepository.findAll();
}
}
PersonRest class:
package ben.web;
@RestController
public class PersonRest
{
@Autowired
private PersonService personService;
@RequestMapping("/person")
public List <Bde> findAll() {
List <Bde> persons=(List<Bde>) personService.findAll();
for (Bde pers:persons)
{
System.out.println("id"+pers.getId() +" numero"+pers.getNumero());
}
return persons;
}
}
POM.XML :dependencies
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>BenId</groupId>
<artifactId>SpringBoot</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<properties>
<start-class>ben.SpringBootWebApplication</start-class>
<java.version>1.8</java.version>
<oracle.driver.version>12.1.0.2</oracle.driver.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- <version>2.8.4.RELEASE</version> -->
<version>2.1.0.RELEASE</version>
</parent>
<dependencies>
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-thymeleaf</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>7.0.52</version>
<!-- <scope>provided</scope> -->
<!-- <version></version> -->
</dependency>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>${oracle.driver.version}</version>
</dependency>
<!-- <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.7</version>
</dependency> -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
<mainClass>ben.SpringBootWebApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
application properties:
spring.mvc.view.prefix:/WEB-INF/jsp/
spring.mvc.view.suffix:.jsp
spring.datasource.url=jdbc:oracle:thin:@12.53.2.202:1521:xe
spring.datasource.username=hr
spring.datasource.password=hr
spring.datasource.driverClassName=oracle.jdbc.OracleDriver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl