我有多个由 Gradle 管理的 Spring Boot 微服务应用程序。有一个通用的 jar 和特定于域的 jar,组织如下:| common/
|-- common.jar
| p/
|-- p-ingest.jar
| g/
|-- g-ingest.jar我的常见 jar 有一个类,BaseRESTService自动装配HttpServletRequest(我已经知道这是一个坏主意 - 不是我的代码)。p-ingest.jar 导入 common,g-ingest jar 也是如此。geoalloc 运行没有问题。但是 p-ingest(实际上是从 g-ingest 复制而来)不会运行。当上下文尝试初始化时,p-ingest 出现以下异常:Field request in com.company.common.BaseRESTService required a bean of type 'javax.servlet.http.HttpServletRequest' that could not be found.我对 Spring 并不陌生,我了解组件扫描和自动装配等所有内容,但我已经为此工作了 2 天,但我无法弄清楚发生了什么。我运行gradle dependencies了这两个项目,树是相同的。下面是p-ingest的启动应用类:@SpringBootApplication@ComponentScan( basePackageClasses = com.company.common.ConfigurationSearchCriteriaFactory.class, basePackages = {"com.company.erd"})@EnableJpaRepositories(basePackages = "com.company.erd")@EntityScan(basePackages = {"com.company.erd"})public class PortfolioRiskIngestApplication implements ApplicationRunner { private static final Log logger = LogFactory.getLog(IngestApplication.class); @Autowired private IngestService ingestService; public PIngestApplication(PIngestService ingestService) {this.ingestService = ingestService;} public static void main(String[] args) { SpringProfileHelper.setProfileFromAwsEnvironment(); SpringApplication app = new SpringApplication(PIngestApplication.class); app.setWebEnvironment(false); app.run(args); } @PostConstruct void started() { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); } @Override public void run(ApplicationArguments applicationArguments) { // define the log info LogInfo info = LogInfo.newInstance("run", new Object[] { StringUtility.arrayToString(applicationArguments.getSourceArgs()) }); // log entry logger.info(info.entry()); ingestService.run(applicationArguments.getSourceArgs()); // log exit logger.info(info.exit()); }}
添加回答
举报
0/150
提交
取消