Spring Boot的被@SpringBootApplication注解的App.java必须放在所有的RestController的根路径的package下

Spring Boot的被@SpringBootApplication注解的App.java必须放在所有的RestController的根路径的package下


如下图。App.java 的package是com.frank.img.controller

UserCardWriterController的package是com.frank.img.controller.writer

这样UserCardWriterController 才能被真正被注册到Spring Boot的RestController上去。


Spring Boot的被@SpringBootApplication注解的App.java必须放在所有的RestController的根路径的package下_第1张图片



/**
 * 
 * @author frank.liu
 */
@SpringBootApplication
public class App 
{
    public static void main( String[] args )
    {
    	String[] paths = { "META-INF/spring/appContext.xml", "META-INF/spring/mybatisContext.xml"};
        ApplicationContext appContext = new ClassPathXmlApplicationContext(paths);
        System.out.println("Step in.1");
        SpringApplication.run(App.class, args);
        System.out.println("Step in.2");
    }
}


你可能感兴趣的:(SpringBoot)