In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you what the Act Framework multi-module development guide is, the content is very detailed, interested friends can refer to, hope to be helpful to you.
ActFramework is a non-lightweight full-stack MVC framework for Java. Compared with other frameworks, the main features of ActFramework are:
Powerful parameter binding. Controller methods can bind any Java type, including primitive types, strings, enum, arrays, collection types, Map types, and user-defined POJO
Flexible routing configuration-support injection and routing table configuration
Dependency injection conforming to the JSR330 standard
Built-in CSRF,XSS protection
Built-in CORS to support SPA front and rear separation
Fully functional database access layer
Complete RESTFul service support
Excellent runtime performance
Support the configuration of different running environments
Support for multiple template engines
Non-Servlet framework, easy to develop and deploy
A variety of plug-ins, including mongodb,Excel output, OAuth authentication, authentication / authorization / accounting, etc.
As a loyal fan of ActFramework, I have seen that Act has become more and more perfect and more mature step by step since Act version 1.0. If you want to develop RESTFul services more quickly, ActFramework is a good choice.
Earlier, Green has shared how to take the first step in the world of ActFramework, to build an Act project from scratch, details can be found here. This blog has been well received by many friends, who are not satisfied with primary use, and many friends have asked more questions about Act in various ways, some of which are about how to create multi-module Act applications and projects. Today, here is how to build multi-module Act applications and projects step by step.
1. Frame engineering
First of all, we construct a multi-module, multi-application project, which mainly meets the following functions.
Released applications should be distinguished from internal modules independently
There may be multiple independent App under the application
There may be multiple sub-modules under the module, depending on the function.
So, the structure we designed is roughly as follows.
Project ├─ applications │ ├─ genji │ ├─ hanzo │ └─ nexus └─ modules ├─ core ├─ data └─ ware
Applications below are three independent applications that will be released in the future, genji,hanzo and nexus
Modules is an internally dependent module of the project, and these modules may be applied wholly or individually.
With the approximate design model of the project, we start to build the project next.
two。 Construction project
Build a project to achieve the above architecture. Maven is used as a management tool here. The specific POM can be found below.
2.1 POM 4.0.0 sonatype-nexus-snapshots Sonatype Nexus Snapshots https://oss.sonatype.org/content/repositories/snapshots false true sonatype- of the project Nexus-snapshots Sonatype Nexus Snapshots https://oss.sonatype.org/content/repositories/snapshots false true org.actframework act-starter-parent 1.8.19.0 me.domall:: project Pom 1.0.1 applications modules 1.0.1 1.0.1 1.0.1 8.0.12 27.0.1-jre 1.2.3 4.12 2.2.0 3.1.0 1.8 UTF-8 UTF-8 Org.apache.maven.plugins maven-compiler-plugin ${java.version} ${java.version} true lines Vars Source org.apache.maven.plugins maven-resources-plugin true org.apache.maven. Plugins maven-assembly-plugin true org.apache.maven.plugins maven-dependency-plugin true
The core part of the top project is to declare that there will be two large modules, applications and modules.
Applications modules 2.2 Application Project
There are three independent Application under the Applications project, here only take the Nexus project as an example, others are similar.
4.0.0 domall me.domall 1.0.1 domall-applications pom domall:: applications hanzo nexus genji me.domall domall-core ${domall-core.version} compile Me.domall domall-data ${domall-data.version} compile me.domall domall-ware ${domall-ware.version} compile Org.actframework act ${act.version} org.actframework act-aaa ${act-aaa.version}
You can see that there are three separate applications, Genji,Hanzo and Nexus, under applications
2.2.1 Nexus Project
Configuration POM of the project
4.0.0 domall-applications me.domall 1.0.1 domall-nexus domall:: applications:: nexus me.domall.nexus.Nexus me.domall domall-core me.domall domall-data Me.domall domall-ware org.actframework act org.actframework act-aaa org.apache.maven.plugins maven-compiler-plugin 2.3 Modules Project
Modules project is similar to Applications project, except that the modules under Module are released as Jar packages, which can only be referenced by other modules or applications.
4.0.0 domall me.domall 1.0.1 domall-modules pom domall:: modules core data ware me.domall domall-core ${domall-core.version} compile Me.domall domall-data ${domall-data.version} compile org.actframework act-aaa ${act-aaa.version} Org.actframework act-morphia ${act-morphia.version} org.actframework act-eclipselink ${act-eclipselink.version} mysql mysql-connector-java ${mysql -connector.version} com.google.guava guava ${guava.version} org.slf4j slf4j-api ${slf4j-api.version} junit Junit ${junit.version} test org.assertj assertj-core ${assertj.version} test
The sub-modules under Modules are consistent with the applications under Applications, and they are not listed here.
3. ACT multi-module support
After reading the previous content, we can find that our multi-module and multi-application project in Act basically looks the same as the Spring project. It is true that Act supports standard Maven architecture engineering, so the multi-module and multi-application engineering of Act is the standard Maven multi-module project.
3.1 IDEA support
Since it is a standard Maven project, we import the project into Intellij IDEA, and after configuring the corresponding IDEA configuration, IDEA is fully identifiable without any problems.
Since IDEA can correctly identify the multi-module application of the Maven standard, what are the doubts and problems?
The main confusion and problem is that when we enable Act Application, it will fail, and IDEA will tell you that you can't find the corresponding referenced module.
Why and how to solve it?
Let's first take a look at how to properly launch a multi-module reference application in IDEA.
3.1.1 configuration support
To solve the problem of starting and executing Act multiple modules under IDEA, we can choose to add the configuration to the configuration file of the project.
Because Act supports multiple environments, we usually launch DEV in IDEA by default, so we need to add relevant configurations to the configuration under Dev.
Here we will take the configuration of the Neuxs project as an example:
# Act multi-modules configuration for DEV####base=../../modulesmodules=$ {base} / core;$ {base} / data;$ {base} / ware
The core of configuration is to configure the modules attribute and specify the relative or absolute position of the module introduced by the application. We recommend using the relative position.
3.2 operational support
Just now we know how to support multiple modules of Act in IDEA. So how can the App application we released support it in the PROD environment? Do you also add the configuration file under Prod?
First of all, we see that App released by Act by default is in the form of tar.gz, which contains our Act dependencies and our own project dependencies, and at startup, resources under lib will be automatically loaded into the running environment, so we do not need to make any changes to the configuration file under Prod, Act Application will automatically find dependent packages placed under lib at startup.
Note:
When we customize multi-module applications, we need to specify the release format and references in the POM, so that our released tar.gz can correctly include the Jar files under the module.
If we need to modify the resource file of the submodule, we can make the corresponding settings and modifications in the POM file. For example:
Org.apache.maven.plugins maven-resources-plugin false ${project.build.outputDirectory} ${project.parent.parent.basedir} / modules/core/src/main/resources false ${project.parent.parent.basedir} / modules/data/src/main/resources False ${project.basedir} / src/main/resources false ${project.basedir} / src/main/resources true * * / .version Org.apache.maven.plugins maven-assembly-plugin false org.apache.maven.plugins maven-dependency-plugin false org.apache.maven.plugins maven-jar-plugin ${maven-jar-plugin.version} me/** 4. Concluding remarks
The multi-module and multi-application of Java project is the setting of standard Maven project. The project of Act is released and can be perfectly supported in the generation environment. No special modifications are required.
In order to support the development mode to find the project source file to compile, you need to declare the Modules configuration in the corresponding Dev configuration. Keep in mind the following configuration, Act multi-module multi-application is not a problem.
Modules=/;/;...
By the way, explain why the Modules parameter needs to be configured under IDEA, but not in the project of Spring. This is because Spring has a special plug-in under IDEA, which tells IDEA where to find the modules introduced by Spring, but Act does not have a special plug-in for IDEA, so we can only declare it in the configuration, so there is nothing wrong with the development mode.
On the Act Framework multi-module development guide what is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.