Sunday, September 16, 2012

Copy maven dependencies to WEB-INF/lib

Use Case

Configure Dynamic Web Project in Eclipse to copy maven dependencies (jars) to WEB-INF/lib.

Solution

1. Update eclipse.ini, specify -vm option

-vm
C:\Program Files\Java\jdk1.6.0_25\bin\

2. Convert project to MAVEN backed, set packaging to WAR.

3. Configure JRE
Go to Project > Properties > Java Build Path > Libraries. Choose JRE System Library and click 'Edit'. Choose Execution Environment from list of available environments, use the same vm as eclipse.ini has.

4. Configure Deployment Assembly
Go to Project > Properties > Deployment Assembly. Click Add button, then choose Java Build Path Entries. Choose Maven Dependencies from the list and click OK.