2.2K Star 15.6K Fork 9.3K

JEECG / jeecg-boot

 / 详情

无法集成Mongo

已完成
创建于  
2021-11-27 20:45
版本号:3.0
问题描述:

我使用单体应用,直接在system模块集成mongo.
运行,一直运行不起,提示错误:

APPLICATION FAILED TO START
***************************

Description:

Field mongoTemplate in org.jeecg.modules.api.controller.SystemAPIController required a bean of type 'org.springframework.data.mongodb.core.MongoTemplate' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'org.springframework.data.mongodb.core.MongoTemplate' in your configuration.


Process finished with exit code 1
截图&代码:

我使用单体应用,直接在system模块集成mongo.
1、在system下的Pom.xml中加入

<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-mongodb</artifactId>
		</dependency>

2、在application-dev.yml中增加Mongo配置

data:
    mongodb:
      database: libo
      host: 127.0.0.1
      port: 27017
      uri: mongodb://127.0.0.1:27017

3、在SystemAPIController中增加

@Autowired
    private MongoTemplate mongoTemplate;

友情提示(为了提高issue处理效率):

  • 未按格式要求发帖,会被直接删掉;
  • 请自己初判问题描述是否清楚,是否方便我们调查处理;
  • 针对问题请说明是Online在线功能(需说明用的主题模板),还是生成的代码功能;
  • 描述过于简单或模糊,导致无法处理的,会被直接删掉;

评论 (11)

李勃 创建了任务

不只是mongo无法集成,其他的都无法集成,烦请大佬帮忙

其他也无法集成是什么意思?

输入图片说明

启动类排除DisabledMongoStartConfig
@SpringBootApplication(exclude= {DisabledMongoStartConfig.class})

JEECG 任务状态待办的 修改为已完成

这个加上后,会影响到积木那个功能吗

java.lang.IllegalStateException: The following classes could not be excluded because they are not auto-configuration classes:
- org.jeecg.modules.jmreport.config.DisabledMongoStartConfig

at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.handleInvalidExcludes(AutoConfigurationImportSelector.java:216)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.checkExcludedClasses(AutoConfigurationImportSelector.java:202)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:126)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:434)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:879)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:809)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:780)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:193)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.jeecg.JeecgSystemApplication.main(JeecgSystemApplication.java:29)
JEECG 任务状态已完成 修改为待办的

换成这个依赖试试, 注意配置私服

<dependency>
  <groupId>org.jeecgframework.jimureport</groupId>
  <artifactId>jimureport-spring-boot-starter</artifactId>
  <version>1.4.11</version>
</dependency>

收到,已经测试通过了。感谢大佬

我今天也测试了mongo集成 也差不多报了 刚测试了 可以了 升级积木版本
输入图片说明

JEECG 任务状态待办的 修改为已完成

你好,我提供的方法可以在不升级的情况,集成mongodb,issues代码已提交,望采纳,有问题请留言,谢谢。

大佬,你的方法可以理解,如果官方不出面的情况下,你这个方法就是终极解决方案了,不然真的就要换框架了。虽然最后我采纳了官方提供的新的积木模块版本解决了这个问题。但是你的代码也很优秀。

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(4)
57093 jeecg 1662000782 13974 lc 1631154031
Java
1
https://gitee.com/jeecg/jeecg-boot.git
git@gitee.com:jeecg/jeecg-boot.git
jeecg
jeecg-boot
jeecg-boot

搜索帮助