mirror of https://github.com/apache/nifi.git
NIFI-12666 Corrected Registry Data Source Configuration (#8299)
This commit is contained in:
parent
89836f32d0
commit
693b187396
|
@ -22,7 +22,7 @@ import org.apache.nifi.registry.properties.NiFiRegistryProperties;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
@ -34,7 +34,7 @@ import javax.sql.DataSource;
|
|||
* Overriding Spring Boot's normal automatic creation of a DataSource in order to use the properties
|
||||
* from NiFiRegistryProperties rather than the standard application.properties/yaml.
|
||||
*/
|
||||
@ConditionalOnProperty("nifi.registry.db.url")
|
||||
@ConditionalOnMissingBean(DataSource.class)
|
||||
@Configuration
|
||||
public class DataSourceFactory {
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.mockito.Mockito;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
|
||||
/**
|
||||
* Sets up the application context for database repository tests.
|
||||
|
@ -31,6 +33,12 @@ import org.springframework.context.annotation.Bean;
|
|||
* The DataSourceFactory is excluded so that Spring Boot will load an in-memory H2 database.
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@ComponentScan(
|
||||
excludeFilters = {
|
||||
@ComponentScan.Filter(
|
||||
type = FilterType.ASSIGNABLE_TYPE,
|
||||
value = DataSourceFactory.class)
|
||||
})
|
||||
public class DatabaseTestApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.nifi.registry;
|
||||
|
||||
import org.apache.nifi.registry.db.DataSourceFactory;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
@ -29,6 +30,9 @@ import java.util.TimeZone;
|
|||
@ComponentScan.Filter(
|
||||
type = FilterType.ASSIGNABLE_TYPE,
|
||||
value = SpringBootServletInitializer.class), // Avoid loading NiFiRegistryApiApplication
|
||||
@ComponentScan.Filter(
|
||||
type = FilterType.ASSIGNABLE_TYPE,
|
||||
value = DataSourceFactory.class), // Avoid loading DataSourceFactory
|
||||
})
|
||||
public class NiFiRegistryTestApiApplication extends SpringBootServletInitializer {
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.nifi.registry;
|
||||
|
||||
import org.apache.nifi.registry.db.DataSourceFactory;
|
||||
import org.apache.nifi.registry.security.authorization.AuthorizerFactory;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
@ -29,6 +30,9 @@ import org.springframework.context.annotation.FilterType;
|
|||
@ComponentScan.Filter(
|
||||
type = FilterType.ASSIGNABLE_TYPE,
|
||||
value = SpringBootServletInitializer.class), // Avoid loading NiFiRegistryApiApplication
|
||||
@ComponentScan.Filter(
|
||||
type = FilterType.ASSIGNABLE_TYPE,
|
||||
value = DataSourceFactory.class), // Avoid loading DataSourceFactory
|
||||
@ComponentScan.Filter(
|
||||
type = FilterType.ASSIGNABLE_TYPE,
|
||||
value = AuthorizerFactory.class), // Avoid loading AuthorizerFactory.getAuthorizer(), as we need to add it again with test-specific @DependsOn annotation
|
||||
|
|
Loading…
Reference in New Issue