0

I'm getting the UnsatisfiedDependencyException exception when starting my SpringBoot Application, my main class has these annotations

@SpringBootApplication
@ComponentScan(basePackages = { "com.xxx.yyy" })
@EntityScan("com.xxx.zzzz")
public class App {
}

My entities annotated with @Entity were included as external jars to classpath, my repository class has the @Repository annotation

@Repository
public interface ClassRepository extends JpaRepository<XXX, BigInteger> {

}

My entity is declared as

@Entity
@Table(name = "MyTable")
public class MyEntityClass implements Serializable {
}

The follow is part of the stacktrace

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'XXXController': Unsatisfied dependency expressed through field 'repositoryXXX';

nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxRepository': Invocation of init method failed;

nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.xxx.yyy.zzz.entities.MyClass

Community
  • 1
  • 1
Gilberto
  • 77
  • 7
  • is your class annotated as an `@Entity` ? – blurfus Feb 11 '20 at 01:23
  • Please add your entity as well as the package declaration to the classes. I would strongly suggest removing the `@ComponentScan` and `@EntityScan` and place your `@SpringBootApplication` class in `com.xxx` package. – M. Deinum Feb 11 '20 at 07:52
  • @M.Deinum I've edited my question, an example of my entity has been added, the ComponentScan and EntityScan were added because my entities are in an external jar file, that are in a different package than my Main Class annotated with the SpringBootApplication annotation – Gilberto Feb 11 '20 at 16:52
  • Please go through this link, it might help: https://stackoverflow.com/questions/28664064/spring-boot-not-an-managed-type – Brooklyn99 Feb 11 '20 at 16:58
  • also I assume there is a chance your entity class has an issue – Brooklyn99 Feb 11 '20 at 17:05
  • All the packages in the application are located as a SpringBoot Application, I'd added the entities package (source code - java classes) (Entities are located in a different package) for testing propourses before creation jar file, that's why I've annotated the main class with EntityScan annotation – Gilberto Feb 11 '20 at 17:23

1 Answers1

-1

Solved, after different aproaches I've created a new jar file but "Add directory entries" option were selected, add the jar to the project and works fine. I guess without the selected option the application doesn't known the folders or packages included in the jar file.

enter image description here

Thanks to everyone.

Gilberto
  • 77
  • 7
  • 1
    Don't... Please don't you are using Spring Boot and you should be using the Spring Boot plugin to create a jar NOT use the IDe to export a jar. – M. Deinum Feb 12 '20 at 06:06
  • @M.Deinum Ok, by the time I will deploy the Application on production I will, Right now I've some issues with the project structure, We will fix it. Thank You. Best regards – Gilberto Feb 12 '20 at 23:57