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

[Enhancement] ShiroRequestMappingConfig's RequestMappingHandlerMapping dependency should be annotated with @Qualifier #1879

Open
1 of 2 tasks
gokepler opened this issue Nov 15, 2024 · 11 comments
Labels
help-wanted Help Wanted java Pull requests that update Java code spring Spring and SpringBoot

Comments

@gokepler
Copy link

Search before asking

  • I had searched in the issues and found no similar issues.

Enhancement Request

avoid "required a single bean, but 2 were found" Exception

Describe the solution you'd like

annotated with @qualifier

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@gokepler gokepler changed the title [Enhancement] ShiroRequestMappingConfig's RequestMappingHandlerMapping dependency should annotated with @Qualifier [Enhancement] ShiroRequestMappingConfig's RequestMappingHandlerMapping dependency should be annotated with @Qualifier Nov 15, 2024
@lprimak lprimak added java Pull requests that update Java code spring Spring and SpringBoot labels Nov 15, 2024
@lprimak
Copy link
Contributor

lprimak commented Nov 15, 2024

Any chance you can submit a PR?
Thank you

@lprimak lprimak added the help-wanted Help Wanted label Jan 1, 2025
@Suvrat1629
Copy link

@lprimak
In the constructor of ShiroRequestMappingConfig, I have to add the @Qualifier annotation to explicitly specify which RequestMappingHandlerMapping bean should be injected.

public ShiroRequestMappingConfig(@Qualifier("requestMappingHandlerMapping") RequestMappingHandlerMapping requestMappingHandlerMapping) 

is this approach right? Do i need to look into anymore files?

@lprimak
Copy link
Contributor

lprimak commented Jan 24, 2025

That's just it, I am not sure. I am not a Spring user and cannot test / verify the correctness of the solution.

However, if I were to "just guess" this does look correct.

If you have a good test that can prove that this works, please feel free to issue a PR, and this will be very much appreciated.

Thank you!

@Suvrat1629
Copy link

Fine I will work on this issue and open a pr accordingly.

@Suvrat1629
Copy link

@lprimak
I am having a bit of difficulty navigating the repo could you please tell me if there is any file that contains the test cases for ShiroRequestMappingConfig.java file? Or do I need to make a separate file for the test cases myself?

@lprimak
Copy link
Contributor

lprimak commented Jan 25, 2025

There are tests in https://github.com/apache/shiro/tree/main/support/spring/src/test directory. Please look there. However I am not sure if that’s what you need. I think that integration test is what’s needed but that doesn’t exist in Shiro for Spring.

I would start with a simple standalone project that demonstrates the issue and that the proposed fix fixes it.

@Suvrat1629
Copy link

Ok that makes sense, I am trying to come up with a standalone project but it is getting too difficult for me because of the various dependencies which i am not generally used to.

@Configuration
public class MultipleBeansConfig {

    @Bean(name = "primaryHandlerMapping")
    public RequestMappingHandlerMapping primaryHandlerMapping() {
        return new RequestMappingHandlerMapping();
    }

    @Bean(name = "secondaryHandlerMapping")
    public RequestMappingHandlerMapping secondaryHandlerMapping() {
        return new RequestMappingHandlerMapping();
    }
}

this is the simple code I came up. Is there anyone who can help me out with this on how i should approach further? I have already opened a pr with the changes

@lprimak
Copy link
Contributor

lprimak commented Jan 26, 2025

Can you be more specific? What dependencies? Can you give a link to your project?

@Suvrat1629
Copy link

The shiro dependencies to be exact the shiro-aspectj and so on, I dont understand where these dependencies are coming from and hence most of my project does not seem to work, is there like a roadmap or something i can follow or anyone to guide me with how i can proceed?

@lprimak
Copy link
Contributor

lprimak commented Jan 26, 2025

Have you been able to start with a simple example? For example https://github.com/apache/shiro/tree/main/samples/spring-boot-3-web ?
That should be more than enough to get you started

@Suvrat1629
Copy link

Ok thank you i will look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted Help Wanted java Pull requests that update Java code spring Spring and SpringBoot
Projects
None yet
Development

No branches or pull requests

3 participants