'Creating an external SpringBoot service that lives in its own jar
I'm trying to create a general purpose springboot service in a jar file that can be used across several applications. To do this I have create a jar file (using maven) that has the following:
A set of three classes and one interface in this single jar. They are in their own distinct package:
package com.hmg.generic.service
MyServiceConfig
MyServiceDataSourceConfig
MyService
IMyService
I have a main application in a separate project, that contains
@ComponentScan(basePackages = {"com.hmg.apps.myapplication","com.hmg.generic.service"})
public class MyApplication extends SpringBootServletInitializer {
My question is, how do I annotate the classes, and do I need any kind of factory method, or helper code, to get the classes in the jar to be instantiated and spun up when the application starts?
When I try to spin up the application I get the following message:
Field config in com.hmg.app.myapplication.MyApplication required a single bean, but 2 were found:
- myServiceConfig: defined in file [/Users/tgia/Development/source/MyApp/GenericService/target/classes/com/hmg/generic/service/MyServiceConfig.class]
- com.hmg.generic.service.MyServiceConfig: defined in null
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
