首页 > 其他分享 >jeecgboot新建子模块问题

jeecgboot新建子模块问题

时间:2023-02-17 11:48:24浏览次数:56  
标签:新建 jeecgboot springframework 模块 org import port jeecg

jeecgboot新建子模块问题

​ 新建子模块后 Controller 接口在 ShiroConfig 中配置了不需要权限访问,但是访问时仍然报错:token 失效

​ 可能原因:新建子模块的包名不是 org.jeecg 作为前缀,导致 @Controller 注解不生效,没有扫描到该组件

​ 解决方法:

​ 增加 @ComponentScan 注解使其扫描到自定义组件

package org.jeecg;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.oConvertUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Repository;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
* 单体启动类
* 报错提醒: 未集成mongo报错,可以打开启动类上面的注释 exclude={MongoAutoConfiguration.class}
*/
@Slf4j
@ComponentScan(value = {"新建子模块包名","org.jeecg"})
@MapperScan(basePackages = "新建子模块包名")
@SpringBootApplication
//@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
public class JeecgSystemApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(JeecgSystemApplication.class);
    }

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(JeecgSystemApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
        log.info("\n----------------------------------------------------------\n\t" +
                "Application Jeecg-Boot is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "/\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "/\n\t" +
                "Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
                "----------------------------------------------------------");

    }

}

​ 注意:还需要增加 @MapperScan 扫描相关 mapper

​ 参考文档:https://github.com/jeecgboot/jeecg-boot/issues/373

标签:新建,jeecgboot,springframework,模块,org,import,port,jeecg
From: https://www.cnblogs.com/Y-wee/p/17129531.html

相关文章