Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Giving bean id by spring annotation way [closed]

Tags:

spring

Let's say I have a class.

@Service
public class SomeService {
    private String name;

    public void setName(String name) {
        this.name = name;
    }

    public void printHello() {
        System.out.println("Spring 3 : Hello ! " + name);
    }
}

The someService bean id is created for this bean by default. I want to change this bean id to say "abc". How would I do that ?

like image 758
Number945 Avatar asked Oct 06 '16 15:10

Number945


1 Answers

@Service("abc") will do the trick you want.

This will applicable for any @Component annotation such as @Service,@Repository and @Controller etc.

like image 55
Sundararaj Govindasamy Avatar answered Nov 13 '22 08:11

Sundararaj Govindasamy