Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make the new entity multipart controller confitional so it doesn… #1803

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.springframework.data.rest.extensions.entitycontent;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.*;
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.util.List;

@Configuration
@Conditional(SpringDataRestPresentCondition.class)
public class RepositoryEntityMultipartConfiguration {

@Bean
Expand All @@ -19,4 +20,5 @@ public void configureHttpMessageConverters(List<HttpMessageConverter<?>> message
}
};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.springframework.data.rest.extensions.entitycontent;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class SpringDataRestPresentCondition implements Condition {

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
try {
context.getClassLoader().loadClass("org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer");
return true; // Spring Data REST is present
} catch (ClassNotFoundException e) {
return false; // Spring Data REST is not present
}
}
}
Loading