I wouldn't use Spring to handle this bean creation, unless you want ALL employees to have the same id and name which I doubt.
The power behind Spring is its Dependency Injection (DI) where you define beans for providers such as database managers, services, etc. and inject those into your components. Defining a @Bean like you have there serves no purpose as now you can only inject employees with an id of 3123 and name John.
It's important to understand that just because you are using Spring it doesn't mean EVERYTHING needs to be handled as a bean - you will always need standard POJOs for housing and passing around state (such as your Employee class) which doesn't need to have anything to do with Spring.
Down the line you might have an EmployeeService for example which houses business logic to fetch employees from a database or something, this could then be configured as a bean so it can be injected across the application.
EDIT
@Configuration public class JavaConfig { @Bean @Autowired //assuming a sessionfactory been is configured elsewhere public EmployeeService employeeService(final SessionFactory sessionfactory) { return new EmployeeService(sessionFactory); } }
You could then inject this anywhere (maybe in a controller for example):
@RestController public class EmployeeController { private final EmployeeService employeeService; @Autowired public EmployeeController(final EmployeeService employeeService) { this.employeeService = employeeService; } }
Where the EmployeeController doesn't need to know or care that the userService has a DB connection and doesn't need to worry about configuring it as Spring will handle all of that.