I found many related questions like this but still I cant make it working. This is the pom.xml of my web-app
<profiles>
<profile>
<id>mysql</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<dialect>org.hibernate.dialect.MySQLDialect</dialect>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost/exercisedb</url>
<username>root</username>
<password>password</password>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp/WEB-INF</directory>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
And this is the bean Im trying to filter in my applicationContext which is in src/main/webapp/WEB-INF/spring/appServlet folder
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
</bean>
I run the application and I got this error
Cannot load JDBC driver class '${driver}'
java.lang.ClassNotFoundException: ${driver}
I assume the properties are not filtered in build time.
EDIT : webapp pom.xml
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp/WEB-INF/spring/appServlet</directory>
<targetPath>WEB-INF/spring/appServlet</targetPath>
<includes>
<include>applicationContext.xml</include>
</includes>
</resource>
</webResources>
Now filtered but using mvn jetty:run, same error I tried deploying to tomcat (not plugin in maven) and it works.