Not able to exclude transitive dependency

Hi, i have a project A where i compile a dependency B (which is another local project) and its using a version of spring-context higher that the one i import in my project A. Im doing this for exclusion:
compile(‘’) {
exclude group: ‘org.springframework’, module: ‘spring-context’
But is not working to exclude it from there.
spring-context is brought by other modules too, but i just want to exclude it from this particular app B . I also tried forcing the version like this:
configurations.all {
resolutionStrategy {
force ‘org.springframework:spring-context:4.1.6.RELEASE’
This seems to work for project A, but this A is also used in another project C, and in there is not recognizing what i did in A, so uses the higher version which i dont want.