Skip to content

@Profile should be able to define profiles to accomplish the 'and' scenario [SPR-15634] #20193

Closed

Description

@spring-projects-issues

Manuel Jordan opened SPR-15634 and commented

The current @Profile's value attribute behaves how an OR

Thus having the following:

@Component
@JmxProfile
@FileProfile
@ManagedResource(description="Admin SimpleFileReaderLoggingWriter")
public class SimpleFileReaderLoggingWriterJmx {

or

@Component
@Profile(value={"jmx","file"})
@ManagedResource(description="Admin SimpleFileReaderLoggingWriter")
public class SimpleFileReaderLoggingWriterJmx {

It behaves: use this bean when the profile is either jmx or file (mostly for the second scenario, seems I need other approach for the first scenario, I mean, an annotation that wraps other annotations)

Seems we need a new attribute that behaves how an AND. It to represents:
use this bean when the profiles are jmx and file

Sadly it is not a @Configuration class where I am able to use the @Profile together with the @Configuration and @Bean to represent the AND scenario. But here we are in the business or model area.

Not sure if exists other approach to accomplish this.

Thank you.


Affects: 4.3 GA, 4.3.8

Reference URL: https://stackoverflow.com/questions/38133808/spring-multiple-profiles-active

Issue Links:

Activity

  1. spring-projects-issues commented on Jun 7, 2017

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Looks like a duplicate of #17063?

  2. spring-projects-issues commented on Jun 7, 2017

    @spring-projects-issues
    CollaboratorAuthor

    Manuel Jordan commented

    Yes, practically the same scenario. But I think is important that perhaps a new annotation for the non @Configuration classes should be created.

  3. added
    in: core
    status: duplicate
    type: task
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: corestatus: duplicatetype: task

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions