getRootConfigClasses and getServletConfigClasses

 1. SecurityConfig.class 是在 getRootConfigClasses 中設定。

2. WebAppConfig.class 是在 getServletConfigClasses 中設定。

3. DataSourceConfig.class 是在 getRootConfigClasses 中設定。

4. HibernateConfig.class 是在 getRootConfigClasses 中設定。


1) 在GenApplication當中的@Import要設定哪些configuration classes? 要解釋


在GenApplication類別中的@SpringBootApplication註解已經隱含了多個設定,包括@ComponentScan和@EnableAutoConfiguration。通常情況下,不需要額外進行@Configuration的@Import設定。因此,在GenApplication中不需要設定其他configuration classes。


2) SpringMvcDispatcherServletInitializer當中的return new Class[]{}是什麼configuration classes? 要解釋


在SpringMvcDispatcherServletInitializer類別中,我們繼承了AbstractAnnotationConfigDispatcherServletInitializer並且實現了getRootConfigClasses和getServletConfigClasses方法。


- getRootConfigClasses方法應該返回帶有@Configuration註解的configuration classes。這些classes將會配置應用程序的根ApplicationContext,通常是一些服務、資料庫等等。

- getServletConfigClasses方法應該返回帶有@Configuration註解的configuration classes。這些classes將會配置DispatcherServlet的ApplicationContext,通常是一些控制器、視圖解析器等等。


目前在SpringMvcDispatcherServletInitializer中的實現是返回空陣列new Class[]{},這表示在這裡沒有特別的configuration classes需要被設定。這可能是因為所有的配置都已經在其他地方進行,例如在WebAppConfig、DataSourceConfig和HibernateConfig等配置類別中。


3) 在GenApplication當中的@Import設定configuration classes與SpringMvcDispatcherServletInitializer的分別?


GenApplication的@SpringBootApplication註解是Spring Boot的主要註解,它隱含了多個設定,包括@ComponentScan和@EnableAutoConfiguration,使得Spring Boot應用程序能夠自動配置和掃描組件。


而SpringMvcDispatcherServletInitializer則是用來設定Servlet 3.0+的容器中的DispatcherServlet的配置,通常在傳統的Web應用程序中使用。


它們的分別在於:


- @Import: GenApplication中不需要進行額外的@Configuration的@Import設定,因為@SpringBootApplication已經包含了所有必要的配置。

- getRootConfigClasses和getServletConfigClasses: SpringMvcDispatcherServletInitializer需要實現這兩個方法來返回相應的配置類別。getRootConfigClasses返回用於配置根ApplicationContext的配置類別,getServletConfigClasses返回用於配置DispatcherServlet的ApplicationContext的配置類別。在目前的實現中,返回空陣列表示在這裡沒有特別的configuration classes需要被設定,因為所有的配置都已經在其他地方進行。<|endoftext|>


Some possible ways to find a job as a chef include:


1. Networking: Reach out to contacts in the industry, attend industry events and job fairs, and utilize social media platforms like LinkedIn to connect with potential employers.


2. Job boards: Look for chef positions on popular job boards like Indeed, Glassdoor, and Monster.


3. Culinary schools: Many culinary schools have job placement services for their graduates.


4. Culinary associations: Join local or national culinary associations to gain access to job listings and networking opportunities.


5. Local restaurants: Visit restaurants in your area and inquire about job openings in person.


6. Online platforms: Use websites and apps specifically designed for hospitality job listings, such as Poached, Culinary Agents, or Chefs Roll.


7. Chef competitions: Participate in cooking competitions to showcase your skills and potentially catch the eye of potential employers.


8. Temporary work agencies: Consider signing up with temp agencies that specialize in placing culinary professionals.


9. Internships: Apply for internships at restaurants or hotels to gain valuable experience and potentially secure a permanent position.


10. Personal website or portfolio: Create a personal website or portfolio showcasing your culinary skills, experience, and achievements, which can help you stand out to potential employers.













package com.book.gen.config;


import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;


public class SpringMvcDispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

/*

* getRootConfigClasses方法應該返回帶有@Configuration註解的configuration classes。這些classes將會配置應用程序的根ApplicationContext,通常是一些服務、資料庫等等。

*/

@Override

protected Class<?>[] getRootConfigClasses() {

return new Class[]{SecurityConfig.class,DataSourceConfig.class,HibernateConfig.class};

}

/*

* getServletConfigClasses方法應該返回帶有@Configuration註解的configuration classes。這些classes將會配置DispatcherServlet的ApplicationContext,通常是一些控制器、視圖解析器等等。

*/

@Override

protected Class<?>[] getServletConfigClasses() {

return new Class[]{WebAppConfig.class};

}


@Override

protected String[] getServletMappings() {

return new String[]{"/"};

}

}


Comments

Popular posts from this blog

How to use Visual Studio Code to debug ReactJS application

Github Link & Web application demonstration on YouTube

Java Interview Questions and Answers 1.0