Skip to content

@ControllerAdvice(basePackageClasses) do the prefix search by package name. [SPR-12509] #17114

Closed
@spring-projects-issues

Description

@spring-projects-issues

Kazuki Shimizu opened SPR-12509 and commented

When use the @ControllerAdvice(basePackageClasses), it has been applied to the other base package's Controller.

e.g)

package io.github.kazuki43zoo.app;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;


@ControllerAdvice(basePackageClasses = io.github.kazuki43zoo.app.AppControllerAdvice.class)
public class AppControllerAdvice {

    @ModelAttribute("appCommonMessage")
    public String commonMessage() {
        System.out.println("AppControllerAdvice#appCommonMessage() called.");
        return "Hello in AppControllerAdvice.";
    }

}

Above @ModelAttribute method has been applied to the Controller under io.github.kazuki43zoo.app and io.github.kazuki43zoo.app1 package.

I think that should not be applied to the Controller under io.github.kazuki43zoo.app1 package.

p.s)
basePackages and value attribute is similar behavior.


Affects: 4.1.2

Reference URL: https://github.com/kazuki43zoo/spring-controller-advice

Issue Links:

Referenced from: commits d1f8968

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions