Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Web Application - platform with components

I am doing a research on how to make a proper structure for my web application. It will be a web application serving as a platform for additional, independent components. The components must be able to map requests by using the @Controller annotaion.

So far I have learned, that:

The platform will be deployed as a .war file on Tomcat. The platform classpath location will contain components in a form of .jar files.

My question is:

  • How to setup the components and the platform, so that platform will make use of the components' @Controllers?

So far I have the platform.war running on Tomcat. It is annotation based Spring configuration.

I also have the first component, it is a single Java class with @Controller annotation and first mapping. For some reason when I include this component in the classpath of the platform and try to access the url mapped in the component, the application returns 404 error. In the log files it says "No mapping found for HTTP request" so it does not initialize the component's @Controller.

For further explanation click here.

like image 242
Piotr Chabros Avatar asked Jun 21 '26 23:06

Piotr Chabros


1 Answers

In your JAR file, create a package defining your namespace, i.e: "com.platformproject.web". Then all you need to do is put the JAR file in WEB-INF/lib (or better use Maven Modules) and scan the annotations at startup:

MvcConfig.java

@EnableWebMvc
@Configuration
@ComponentScan(basePackages = { "com.platformproject.web" })
public class MvcConfig extends WebMvcConfigurerAdapter { ... }
like image 150
Stefan Avatar answered Jun 23 '26 17:06

Stefan