what does Spring Boot multiple modules project's classpath look like? - spring-boot

I am developing a multi-modules project with Spring Boot, and it always confuse me that what does its class path look like .
My project looks like this:
project
|-- module1
| |-- src
| | `-- main
| | |-- java
| | `-- resources
| | |-- /params/applicationContext.xml
| |
| `-- pom.xml
|-- module2
| |-- src
| | `-- main
| | |-- java
| | | `--GetPropertyUtils.java
| | `-- resources
| | `-- /params/batch-jobs.xml
| `-- pom.xml
If Module1 is my web module and module2 is a CommonUtil module,
When the server is started, are two property files(batch-jobs.xml and applicationContext.xml)' classpath the same(which are /resources/params)?
Ist there any document I can learn from?

Related

Package Vue frontend in Go binary

I am trying to serve my frontend using the Gin framework. It is a small project which would make maintenance easier having it as a single binary.
The project structure looks like this:
Project
|
+-- backend
| |
| +-- backend (binary)
|
+-- frontend
| |
| +-- dist
| |
| +-- package.json
|
+-- Procfile
|
+-- .gitlab-ci.yml
Currently I am serving the fronend like this:
r.Use(static.Serve("/", static.LocalFile("../frontend/dist", false)))
For local dev this works fine and I did not have any issues. If I deploy this with my gitlab-ci pipeline it fails as I do not upload the ../frontend/dist directory. I looked at the pkgr library which should help me achieve my goal.
My issue is I can not get it to work with the Gin framework. Current snippet:
test := pkger.Dir("../frontend/dist")
r.Use(static.Serve("/", static.LocalFile("../frontend/dist", false))) <- compiles but does not serve frontend
r.Use(static.Serve("/", static.LocalFile(test, false))) <- Does not compile
Is there an easier way to achieve my goal?
The problem is when you deploy the project to Heroku (I supposed you are using Heroku because of the tag you are using) it compiles the Go to a binary.
The binary is running in the root folder of the project and ../frontend is not in the same path as the development enviroment anymore.
Something like this:
Project
|
+-- backend
| |
| +-- backend (binary)
|
+-- frontend
| |
| +-- dist
| |
| +-- package.json
|
+-- Procfile
|
+-- .gitlab-ci.yml
|
+-- project binary <---- here
So the correct path is ./frontend/ (see one dot)
You can set an environment variable to set the correct path.
As you are using Vue, you can set for the development environment a dev-server with a proxy pointing to backend. Then when building for production you can make Vue compiles to a specific folder that is hardcoded and served by the backend.

Spring CLI generates unexpected project structure

When I generate a project with the webpage https://start.spring.io/ and with the configuration: ["group: com.foo", "artifact: bar", "build: maven", "spring boot version: 1.4.2"] I get the following project structure:
folder-name/
|-- mvnw
|-- mvnw.cmd
|-- pom.xml
|-- src
|-- main
| |-- java
| | |-- com
| | |-- foo
| | |--BarApplication.java
| |-- resources
| |-- application.properties
|-- test
|-- java
|-- com
|-- foo
|--BarApplicationTests.java
And when I generate a project with the Spring CLI command:
"spring init -g=com.foo -a=bar -name=bar --build=maven foo-bar" I get the following project structure:
folder-name/
|-- mvnw
|-- mvnw.cmd
|-- pom.xml
|-- src
|-- main
| |-- java
| | |-- com
| | |-- example
| | |--BarApplication.java
| |-- resources
| |-- application.properties
|-- test
|-- java
|-- com
|-- example
|--BarApplicationTests.java
Whatever config I use with Spring CLI. I always get the folder structure "src/java/{top-level domain}/example".
Why is the folder after the top-level domain always named "example", how do I avoid this so that it uses the group and artifact properly so that I get: "src/java/{group's top-level domain}/{group's domain}"?
I guess -a and -g are not correct spring cli params. Only name works fine.
Please referr to How do I use the Paremeters listed in spring init --list.
Specifying the --package-name parameter solved it.

How to maven multiple directories in java?

Im having 2 seperate packages under src folder. i wonder how to maven this project?
src
-- com.firstpackage
-- com.secondPackage
As long as they are in one src folder this should not be a problem.
Your typical maven project will look like this:
my-app
|-- pom.xml
`-- src
|-- main
| `-- java
| `-- com
| `-- mycompany
| `-- app
| `-- App.java
`-- test
`-- java
`-- com
`-- mycompany
`-- app
`-- AppTest.java
So even if you have many packages/folders within src/ that should be no problem.
There is a good guide here how to set up a maven project in 5 mintues.

MVN Site doesn't bring Project Modules structure properly

I have project like this.
MainProject
|
+- SubProject1
|
+- SubProject2
|
+- SubProject3
And i am trying to execute MVN SITE command. I am able to setup all other section in Project Information Section.
All sub module's POM.XML have SubProject1 entry for this.
that's why i am able to see that module name in Project Modules Section.
But when i am trying to click the submodule link it's looking for HTML file under PARENT PROJECT so something like this.
MainProject/target/site/SubModule1/index.html
Actually that location i don't find anything. So what is the correct approach for MultiModule structure SITE creating ?
Looking for some good multi module material or website to read on this and which can fix my issue. Or if you have guys have any POM.XML to use it please post it here.
Indeed, the hierarchy in your IDE (Eclipse ?)does not follow the one which will be produced if you run site:deploy (using the distributionManagement section).
When you will generate the site with site:deploy, it will put all elements in (up to apache http server conventions for example) :
/var/htdocs/
|
+- /MainProject
|
+---/SubProject1
| |
| +--- /index.html
|
+--- /SubProject2
| |
| +--- /index.html
|
+--- /SubProject3
| |
| +--- /index.html
|
+--- /index.html
And you have physically in your workspace :
D:/workspace/
|
+- /MainProject
|
+---/SubProject1
| |
| +--- /target
| | |
| | +--- /index.html
|
+--- /SubProject2
| |
| +--- /target
| | |
| | +--- /index.html
|
+--- /SubProject3
| |
| +--- /target
| | |
| | +--- /index.html
|
+--- /target
| |
| +--- /index.html
So, you have one level more between root projects and file than when it's deploy. This structure is not suitable for links which are created aiming a site:deploy :)
If I'm mistaken on your issue, tell me, but it sounds like quite common.

Rails 3.1 asset pipeline vendor/assets folder organization

I'm using the jQuery Tools scrollable library in my Rails 3.1 site with the various assets placed in the vendor/assets folder and it works great.
My question is regarding the best way to organize the various files under vendor/assets. What is the recommended way to organize vendor/assets subfolders? Currently I have this structure:
vendor/assets/
|-- images/
| |-- scrollable/
| <various button/gradient images>
|-- javascripts/
| |-- scrollable/
| jquery.tools.min.js
|-- stylesheets/
| |-- scrollable/
| scrollable-buttons.css
| scrollable-horizontal.css
This is a fairly un-DRY what to do this. I feel that all of the 'scrollable' items should be under one folder.
What is the recommended way to do this without having to manipulate the asset pipeline load paths?
Thanks!
You could organise them this way, which is slightly better in that it keeps stuff related to the plugin in one directory:
vendor/assets/scrollable
|-- images/
| |-- <various button/gradient images>
|-- javascripts/
| |-- jquery.tools.min.js
|-- stylesheets/
| |-- scrollable-buttons.css
| scrollable-horizontal.css
I am pretty sure this will work as rails globs all directories under assets/.

Resources