Maven项目在本地工作,但不在docker compose上工作

我有一个java项目,我可以通过使用

./mvnw spring-boot:run

使用以下指令集通过docker compose运行的同一项目将不会运行:

在docker-compose.yml内部:

project:
    build: ./project
    ports:
      - 8080:8080

在项目目录的Dockerfile中:

ENTRYPOINT ["./mvnw","spring-boot:run"]

现在有趣的是,在使用docker-compose时,我得到了以下异常消息:

InvocationTargetException: Invalid bean definition with name 'redisTemplate' defined in class path resource [****/****/****/****/****/config/RedisContextConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=****.****.***.***.redis.config.RedisContextConfiguration; factoryMethodName=redisTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [***/***/**/***/**/config/RedisContextConfiguration.class]] for bean 'redisTemplate': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appConfiguration; factoryMethodName=redisTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [***/****/***/***/config/AppConfiguration.class]]

我之前收到了完全相同的错误,但我通过将以下行添加到application.properties文件来设法避免它:

spring.data.redis.repositories.enabled=false

现在这告诉我,不知何故,docker-compose看不到对application.properties所做的更改。因为容器不能运行,所以我不能使用docker exec来仔细查看里面的文件,看看application.properties里面有什么。

有没有办法访问用于创建容器的镜像中的这个.properties,这样我就可以确认我对该属性不存在的怀疑?是否还有其他原因导致项目在本地运行,而不是使用docker?谢谢你的帮助。

转载请注明出处:http://www.ommtl.com/article/20230526/1330843.html