Good evening,
I have an application using Spring boot 1.5.10. I am trying to connect to the oracle database, but I always have the title error.
Attempts:
- I have already returned the version of spring boot (which stopped giving the error, but returned a blank json and on the console it appeared as if it were doing the HQL query, but in that previous version it gave several problems in port 8080) li>
- I have already taken and added hibernate;
- I have run mvn dependency: purge-local-repository + maven update;
- I've already changed my bank.
Model
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Tconta {
@Id
@GeneratedValue
private Long codigo;
private Double valor;
(...)
public Long getCodigo() {
return codigo;
}
public void setCodigo(Long codigo) {
this.codigo = codigo;
(...)
Controller
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import br.com.academia.model.Tconta;
import br.com.academia.repository.Contas;
@RestController
@RequestMapping("/contas")
public class ContaController {
@Autowired
private Contas ContasRepository;
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<List<Tconta>> show()
{
return new ResponseEntity<List<Tconta>>(ContasRepository.findAll(),
HttpStatus.OK);
}
}
Repository
package br.com.academia.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import br.com.academia.model.Tconta;
public interface Contas extends JpaRepository<Tconta, Long>{
//public Tconta findByCode(int codigo);
}
POM
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!--Ja testei com e sem a hibernate-entitymanager-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.3.Final</version>
</dependency>
</dependencies>
message in the console
Error starting ApplicationContext. To display the auto-configuration report
re-run your application with 'debug' enabled.
2018-02-06 00:26:24.649 ERROR 7104 --- [ main]
o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'entityManagerFactory' defined in class path resource [org/
springframework/ boot/ autoconfigure/ orm /jpa /
HibernateJpaAutoConfiguration.cl
ass]: Invocation of init method failed; nested exception is
java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
at
org.springframework. beans. factory. support.
AbstractAutowireCapableBeanFactory.initializeBean (
AbstractAutowireCapableBeanFactory.java:1628 ) ~[ spring-beans-
4.3.14.RELEASE.jar:4.3.14.RELEASE]
at (...)
Caused by: java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile