今天打开自己很久没有运行过的项目,发现未登录访问非登录页面也没有进行跳转,过滤器居然失效了,原来是项目重构的时候修改了包名,路径不正确造成的。
原来的项目是单体架构,并没有在cn.edu.sgu.www包的基础上再细分
package cn.edu.sgu.www.fresheveryday;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnableDiscoveryClient
@SpringBootApplication
@ServletComponentScan("cn.edu.sgu.www.filter")
public class FresheverydayApplication {
private final static Logger logger = LoggerFactory.getLogger(FresheverydayApplication.class);
public static void main(String[] args) {
if (logger.isDebugEnabled()) {
logger.debug("启动天天生鲜超市......");
}
SpringApplication.run(FresheverydayApplication.class, args);
}
}
修改后,多了一层包fresheveryday,在@ServletComponentScan注解后面的路径中新增1级包名
package cn.edu.sgu.www.fresheveryday;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnableDiscoveryClient
@SpringBootApplication
@ServletComponentScan("cn.edu.sgu.www.fresheveryday.filter")
public class FresheverydayApplication {
private final static Logger logger = LoggerFactory.getLogger(FresheverydayApplication.class);
public static void main(String[] args) {
if (logger.isDebugEnabled()) {
logger.debug("启动天天生鲜超市......");
}
SpringApplication.run(FresheverydayApplication.class, args);
}
}