Error using maven profiles

Posted by user3127896 on Stack Overflow See other posts from Stack Overflow or by user3127896
Published on 2014-08-24T16:10:05Z Indexed on 2014/08/24 16:20 UTC
Read the original article Hit count: 152

Filed under:
|
|
|

I've added two profiles to my application and that how it looks:

<profiles>
        <profile>
            <id>dev</id>
            <properties>
                <db.username>root</db.username>
                <db.password>root</db.password>
                <db.connectionURL>localhost:3306</db.connectionURL>
                <db.driverClass>com.mysql.jdbc.Driver</db.driverClass>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <db.username>prodroot</db.username>
                <db.password>prodpass</db.password>
                <db.connectionURL>localhost:3306</db.connectionURL>
                <db.driverClass>com.mysql.jdbc.Driver</db.driverClass>
            </properties>
        </profile>
    </profiles>

In my jdbc.properties file i changed values like this:

jdbc.driverClassName=${db.driverClass}
jdbc.dialect=org.hibernate.dialect.MySQLDialect
jdbc.databaseurl=jdbc:mysql://${db.connectionURL}/dbname
jdbc.username=${db.username}
jdbc.password=${db.password}

And here's bean from spring-container.xml

<bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
        p:driverClassName="${jdbc.driverClassName}"
        p:url="${jdbc.databaseurl}" p:username="${jdbc.username}"
        p:password="${jdbc.password}" />

When i try to deploy my application i got following error:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Could not resolve placeholder 'db.driverClass'

Structure of project:

enter image description here

Any ideas what i'm doing wrong? Thanks in advance!

© Stack Overflow or respective owner

Related posts about java

Related posts about spring