Reputation: 9088
I have a spring boot(1.4.3.RELEASE) application with MySQL as a backend. Using Spring Data with Oracle UCP and MySQL Java connection for connection pooling. Now, trying to move it to a multi module project. Hence my project structure is as follows.
parent project
|---pom.xml -> This is a parent pom.
|---common
|---pom.xml
|---src
|---model
|---pom.xml
|---src
|---service(Interface only)
|---pom.xml
|---src
|---service Impl(Implementations only)
|---pom.xml
|---src
|---repository(Spring Data)
|---pom.xml
|---src
|---web
|---pom.xml
|---src
My parent pom.xml is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
<relativePath />
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>Test Project</name>
<description>Test components</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<version.spring.boot>1.4.3.RELEASE</version.spring.boot>
<version.mysql.connector>6.0.5</version.mysql.connector>
<version.slf4j>1.7.21</version.slf4j>
</properties>
<dependencyManagement>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${version.spring.boot}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${version.slf4j}</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>cc-model</module>
<module>cc-common</module>
<module>cc-dbrepo</module>
<module>cc-dbservice</module>
<module>cc-dbserviceimpl</module>
<module>cc-web</module>
</modules>
</project>
Application.java in web:
@SpringBootApplication(scanBasePackages =
{ "com.test.dbrepo.service.impl", "com.test.db.service", "com.test.dbrepo.repository" })
public class DialerApplication {
web pom.xml:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>com.cc.dialer</groupId>
<artifactId>cc-dbservice</artifactId>
<version>${project.version}</version>
</dependency>
In my repository pom.xml, I have spring-data
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
My DataSource code and the repositories are there in repository project. I have my Spring security code in web module which uses Service module thru injection.
I am getting the below error when i start my web module application.
Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.cc.test.db.service.UserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Is there any other config missing.
Beans in the service impl module is not getting discovered when starting.
Thanks
Upvotes: 6
Views: 4200
Reputation: 618
Package com.cc.test.db.service is not scanned according to your configuration.
Add it.
Your annotation should look like this:
@SpringBootApplication(scanBasePackages =
{ "com.test.dbrepo.service.impl", "com.test.db.service", "com.test.dbrepo.repository", "com.cc.test.db.service" })
Upvotes: -1