-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMerge-SpringBoot-Angular
More file actions
71 lines (50 loc) · 2.22 KB
/
Merge-SpringBoot-Angular
File metadata and controls
71 lines (50 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
This file explains how to integrate the Spring boot backend project with the frontend Angular 2+ project so that you need just one port number to access the application
1. Create a spring boot project normally using spring initializer or any other method
2. In the top of the folder create a subdirectory called "frontend"
3. cd to "frontend" and create the angular app
4. Once all the development is done we need to instruct maven to build the frontend project first
and then include the compiled files into "src/main/resources/public" folder
5. To do so change the content in "angular.json" file of your frontend project assuming that your angular project is created in frontend/<angular project name>
"outputPath": "../../src/main/resources/public/",
6. Once that is done, you need to instruct the maven to include those packages while building the backend application
7. Add the below contents to your "pom.xml"
<build>
<plugins>
...
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>ng</executable>
<workingDirectory>frontend/<INSERT YOUR ANGULAR PROJECT NAME HERE></workingDirectory>
<arguments>
<argument>build</argument>
</arguments>
</configuration>
</plugin>
...
...
</plugins>
</build>
8. Add the below line in <build> section to generate the jar file without any version. If you want the version then ignore this.
<build>
...
...
<finalName>${project.artifactId}</finalName>
<build>
9. Now cd to the top of your project
10. Build the project using the command
mvn package
10. The new packages are stored in target/ folder
11. Start the application using
java -jar target/<filename>.jar