Can't find bean from dependence project in multi-project web application


(simonz) #1

Hello,

I have a web application with Gradle build which is working fine. Now I am developing another web application which will need some existing function (service, entity) of current webapp. The natural thinking is to seperate those functions into a shared common library. So I seperate the working code into a mulit-project layout.

myproject

sub-project mycommon

sub-project mywebapp

I am able to build mycommon project into a mycommon-1.0-jar.

In mywebapp gradle.build, I have compile dependence on mycommon-1.0-jar. mywebapp builds fine with mycommon-1.0.jar in the generated war file. But I can’t start the web app in Eclipse (tomcat). It complains some class from mycommon project is missing.

The build.gradle for mywebapp is quite simple as

apply plugin: ‘eclipse-wtp’

apply plugin: ‘war’

dependencies {

compile group : ‘com.mycomapny’, name : ‘tmycommon’, version : ‘1.0’

} Question 1: What could be the possible cause, anything missing?

Question 2:

What’s difference if I use

dependencies {

compile project(’:mycommon’)

}

vs

dependencies {

compile group : ‘com.mycomapny’, name : ‘tmycommon’, version : ‘1.0’

}

Question3: Can I some Hibernate entities and Spring Data DAO in mycommon and has its own context file? If so, how those context file being loaded in mywebapp?

Thanks, Simon