Java – web app running grunt and Tomcat servers (spring, angular, grunt, maven, Tomcat)
OK, so I've been reading several other stack problems and trying to piece them together without much luck Basically, my method is that I currently have a project with multiple subprojects I basically have the following points:
root |----backend |----|----src |----|----|----main |----|----|----|----java (individual java files not shown) |----|----|----|----resources |----|----|----|----|----Meta-INF |----|----|----|----|----|----applicationContext.xml |----|----|----|----webapp |----|----|----|----|----WEB-INF |----|----|----|----|----|----web_servicesConfig.xml |----|----|----|----|----|----web.xml |----|----pom.xml |----deploy |----|----src |----|----|----main |----|----|----|----resources (properties files for tomcat) |----|----pom.xml |----frontend |----|----app |----|----|----angular files |----|----bower_components |----|----|----bower files |----|----bower.json |----|----Gruntfile.js |----|----pom.xml
OK, I hope the file structure is clear enough I'm going to use Maven - grunt - plugin, so I can run my grunt command on the front end The front end is basically the same as the setting generated by the angle, or at least the target The deployment only sets tomcat, and the back-end saves spring 4 restful services / APIs
OK, that's why I was confused and asked for help I don't know how to make the front end and back end work properly Basically, I wonder if there is a way to tell Maven to start Tomcat and grunt servers in development mode so that I can use their two functions to quickly develop my project, and then pull the Min file into the war of production build I don't think I can figure out how to integrate everything well I checked this question, but I am still confused:
How to deploy AngularJS app and Spring Restful API service on the same domain/server?
I want any link to the tutorial to solve how to use Maven with tomcat, spring, angularjs and grunt... Also the pavilion, so I can use it for my front-end package management I have read several examples and have seen a lot of discussion on how to use spring in Java EE and JSP Or use gradle to do something I want... But I haven't tried
Of course, if this is a bad way to let me know Basically, I want to keep my subprojects as separate as possible while still allowing developers to import / run from a POM file
Solution
From your question, I only dug up two questions
>How to use grunt / bower Tomcat for continuous development > how to deploy production
1 – sustainable development
The solution I chose - because you have used the API to communicate with the client < - > server - is completely separate from the two projects
What does that mean? For me, there are two different repositories One for the client and one for the server, so you get few benefits:
>Split project work (front end / server side) > easy maintenance > if you want to support "API only", for example, mobile applications, etc
But – how do they communicate during development?
This is a good problem: one solution is to run two servers in parallel on localhost, namely MVN clean Tomcat: Run - P yourprofile; Grunt server
But – if I try to access the server side from a different port from the client, will I get cross domain? You're right. Here you get help from grunt and its plug - ins Grab a copy of the grunt connect proxy
What are the benefits of this plug-in? It acts as the middleware between the grunt server and the Tomcat server, so you ask the API of the grunt server, but in fact, grunt asks the Tomcat server to answer (behind the scenes, of course)
2 – deployment for production
I think it's a matter of personal preference I found that war files are very large and uploaded again and again (even if you can share lib among all your Tomcat applications) The solution I came up with was to deploy through GIT
OK, but I have a big war file How can I do this?
For me, I use the deployment script I wrote in bash That's what it does:
>Mark current source > Run MVN clean package War: Explosion - p your prod profile (this will also run tests and integration tests) > using the above command, you can get all the compiled project files in one place instead of a large war file. > Copy all these files (and internal paths) to an external folder (I use another repository for maintenance deployment through GIT. So basically, I have three repositories. One for server source, one for client source and one for server binary files.) > Before executing 4, please make sure to delete all files and folders (except. GIT) > after 4, do "git add - a" > "git commit - A - M 'new production version x" > you can mark some marks before and after so that you can easily recover the last code in case of a big error in the new production > run the remote command on the server to.) Stop the server, b.) extract the last changes from the binary repository, C.) run the server again. > For me, what I do is symbolic links between Tomcat applications and external folders (binary repositories)
I hope this will give you some instructions,
Best score, oak