Meaning of Different Annotation

Annotation Meaning of that Annotion
@SpringBootApplication  
@Order To provide our own execution order for multiple runners
@Component Creating Object to Our Class
@Controller Creating Object to Our Class+Web Application-MVC (HTTP Request)
@RestController Creating Object to Our Class+WebServices+JSON/XML
@Service Creating Object to Our Class+Transaction Management,Locic,Calculation
@Repository Creating Object to Our Class+Database Operation
@ComponentScan(basePackages = "com.app.test") externally at stater class, then default rule is ignored/overriden in App Config
@PropertySource("sunil.properties") specify the property file name in spring using AppConfig
@Primary Select any one child manually using by adding  at child level class
@Qualifier("childObject") Select Manually one Child Object,if multiple Object
Controller Level Annotation
@Controller Creating Object to Our Class+Web Application-MVC (HTTP Request)
@RequestMapping("/registrationcontroller") If there are multiple controller the you need to specify the controller name 
@GetMapping("/register")  
@PostMapping("/save")  
@Autowired  
    StudentRepository repo;  
To Create Instance Variables or inject  a object
   
@Data
@AllArgsConstructor
@NoArgsConstructor
Lombok Annotation to generater No Argument Constructor, All argument constructor and generate geter seter annotation
Model Level  Annotation:
    @Entity
    @Table(name="Student")
Create table name "Student" in Database
    @Id
    @GeneratedValue
    @Column(name="sid")
    private int id;
Create Field "sid" with primary key and autogenerated .
Model Level  Collection Mapping Annotation:
    @ElementCollection
    @CollectionTable(name="Client",
            joinColumns = @JoinColumn(name="sid")
            )
    @Column(name="client")
    private Set empClient;
Set Collection Mapping, Create another table "client" with Forign key "sid"

    @ElementCollection
    @CollectionTable( name="Language",
            joinColumns = @JoinColumn(name="sid"))
    @OrderColumn(name="lanid")
    @Column(name="language")

    private List empLangs;

List Collection Mapping, Create another table "language" with Forign key "sid"

  @ElementCollection
  @CollectionTable(name="Module",
          joinColumns = @JoinColumn(name="sid") )
    @MapKeyColumn(name="moduleid")
    @Column(name="modulename")
    private Map<String,String> empModule;   

Map Collection Mapping, Create another table "client" with Forign key "sid"

Model Level  Association Mapping Annotation:

 

 

JUNIT Annotation

@TestMethodOrder(OrderAnnotation.class)

We can define multiple test methods inside Testcase.Those are executed in Random order by default.

@Order(5)

We can specify our own order using @TestMethodOrder + OrderAnnotation Here we need to provide @Order(number).

@DisplayName("Description")

This annotation is used to provide 'Readable text' inplace of actual method and class names at JUnit console.

@RepeatedTest(value=3)

 

@BeforeAll

To execute any logic once per test case before starting.

@AfterAll 

To execute any logic once per test case after finishing.

@BeforeEach

To execute any logic once per test method before starting test method.

@AfterEach  

To execute any logic once per test method after finishing test method.

@Disabled

This annotation is used to specify Ignore one Test-method  while executing test-case (do not execute test method)

@Tag  

These are used to filter test methods for execution in different environments.

@RepeatedTest

To execute any test method multiple time (like batch processing) using @RepeatedTest annotation.

public void testMultiple(TestInfo info) {
    System.out.println("HELLO:"+info.getTestClass().get().getName());

}

To know our Test case details like classname,method name, display name,tag name etc we can use one interface TestInfo.

application.properties file

# Default Port:8080
server.port=9898

# View Resolver details
spring.mvc.view.prefix=/WEB-INF/pages/
spring.mvc.view.suffix=.jsp

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/boot8pm
spring.datasource.username=root
spring.datasource.password=mysql

spring.jpa.show-sql=true
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
spring.jpa.hibernate.ddl-auto=update