title: The annotation @Bean is disallowed for this location error
body: <p>I read in a book that whenever we want a Java-based configuration and want define a bean we use <code>@Bean</code> annotation. But when I did that I got the error: <code>The annotation @Bean is disallowed for this location</code>. My bean is:</p>
  
  <pre><code>package com.mj.cchp.bean;
  
  import javax.validation.constraints.Digits;
  import javax.validation.constraints.NotNull;
  
  import org.springframework.context.annotation.Bean;
  
  import com.mj.cchp.annotation.Email;
  
  @Bean
  public class UserBean {
  
      @NotNull
      @Email
      private String email;
      @NotNull
      private String firstName;
      @NotNull
      private String lastName;
      @Digits(fraction = 0, integer = 10)
      private String phoneNo;
      @NotNull
      private String role;
  
      public String getEmail() {
      return email;
      }
  
      public String getFirstName() {
      return firstName;
      }
  
      public String getLastName() {
      return lastName;
      }
  
      public String getPhoneNo() {
      return phoneNo;
      }
  
      public String getRole() {
      return role;
      }
  
      public void setEmail(String email) {
      this.email = email;
      }
  
      public void setFirstName(String firstName) {
      this.firstName = firstName;
      }
  
      public void setLastName(String lastName) {
      this.lastName = lastName;
      }
  
      public void setPhoneNo(String phoneNo) {
      this.phoneNo = phoneNo;
      }
  
      public void setRole(String role) {
      this.role = role;
      }
  }
  </code></pre>