Я использую Spring boot 2.2.7 с spring-data-mongodb. IDE: Intellij Idea Community Edition 2020.
У меня есть проект common , в котором размещены общие модели, репозиторий и службы, и еще один, в котором размещены контроллеры с именем gateway . Все работало нормально, пока я просто не переименовал перечисление с NodeTypeEnum в PoductTypeEnum в проекте common .
при запуске пружины шлюз приложение Я получаю
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'servicesConf': Unsatisfied dependency expressed through field 'catalogRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'catalogRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property nodeType found for type Product!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
код ошибки:
Enum ( общий проект)
public enum ProductTypeEnum {
SENSOR,
FIELD,
SINK,
BASE_STATION,
DATA_CENTER
}
класс с использованием перечисления ( общий проект)
@Data
@EqualsAndHashCode
@Document(collection = "catalog")
public class Product implements Serializable {
@Id
private String _id;
/* internal UUID */
@Indexed(unique = true)
@Setter(AccessLevel.NONE)
private String uuId = new UdcId().getValue();
@Indexed
private ProductTypeEnum productType;
........
репозиторий каталога (** общий * проект)
@EnableMongoRepositories
public interface CatalogRepository extends MongoRepository<Product, String> {
@Query(sort = "{'model':1}")
public List<Product> findAllByCapabilitiesContaining(String capability, Pageable paging);
@Query(sort = "{'model':1}")
public List<Product> findAllByModel(TextCriteria model, Pageable paging);
@Query(sort = "{'model':1}")
public List<Product> findAllByModelIsContainingIgnoreCase(String model, Pageable paging);
@Query(sort = "{'model':1}")
public List<Product> findAllByNodeType(ProductTypeEnum nodeType, Pageable paging);
public List<Product> findAllByManufacturerIsContainingIgnoreCase(String manufacturer, Pageable paging);
public Product findByUuId(String uuId);
@Query(sort = "{'model':1}")
public List<Product> findAllBy(Pageable paging);
}
service.conf ( шлюз project)
@Configuration
@EnableMongoRepositories
public class ServicesConf {
@Autowired
CatalogRepository catalogRepository;
@Autowired
ComponentRepository componentRepository;
@Autowired
ParamRepository paramRepository;
@Autowired
SensorRepository sensorRepository;
@Autowired
OrganizationRepository organizationRepository;
@Autowired
SampleRepository sampleRepository;
@Bean
CatalogPersistenceService catalogPersistenceService() {
return new CatalogPersistenceService(catalogRepository, stockPersistenceService());
}
@Bean
ParamPersistenceService paramPersistenceService() {
return new ParamPersistenceService(paramRepository);
}
@Bean
SensorPersistenceService sensorPersistenceService() {
return new SensorPersistenceService(sensorRepository);
}
@Bean
OrganizationPersistenceService organizationPersistenceService() {
return new OrganizationPersistenceService(organizationRepository);
}
@Bean
StockPersistenceService stockPersistenceService() {
return new StockPersistenceService(componentRepository, this.sensorPersistenceService());
}
@Bean
SamplePersistenceService collectPersistenceService(){
return new SamplePersistenceService(sampleRepository);
}
}
Это очень странно, поскольку кажется, что старое свойство nodeType где-то запомнено. Я проверил, что jar, созданный проектом сборки common , был обновлен в репозитории maeven, все в порядке. Я аннулировал идею кеширования / перезапуска, перестроил проект. даже переименование ProductTypeEnum обратно в NodeTypeEnum ничего не решит.
Есть идеи?
заранее спасибо.
шлюз pom. xml
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.open_si</groupId>
<artifactId>udc-gateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Gateway</name>
<description>Gateway for UDC project</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.open_si</groupId>
<artifactId>udc-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
РЕШЕНИЕ
Зависимость spring-start-web отсутствовала в шлюзе пом. Проекта xml