1

I tried multiple solution on SO and none worked on centos 7

i have:

$ echo $DBSERVER
mongodb://0.0.0.0:27017

application.properties

db.server=${DBSERVER}

my config

@Configuration
public class MongoConfiguration extends AbstractMongoConfiguration {
    @Value("${db.server}")
    private String server;
    ...

    @Override
    public MongoClient mongoClient() {
        return new MongoClient(
                new MongoClientURI(server)
        );
    }
}

i tried:

Spring Could not Resolve placeholder

Could not resolve placeholder in string value

Could not resolve Spring property placeholder

Spring Could not Resolve placeholder

Spring boot could not resolve placeholder in string

also i tried to add filtering but its not working

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>

but i still get:

Error creating bean with name 'mongoConfiguration':
  Injection of autowired dependencies failed;
  nested exception is java.lang.IllegalArgumentException:
  Could not resolve placeholder 'DBSERVER' in value "${DBSERVER}"
yenk
  • 219
  • 2
  • 12

0 Answers0