I'm working on a AngularJS project with Spring Boot and the HTML/JS/CSS are placed inside src/main/ressources/static.
The problem is that if I change these files outside Eclipse and refresh the browser the changes are not reflected. Previously I worked on a project where the HTML/JS/CSS files where placed in src/main/webapp folder and I didn't have this kind problem.
I'm required to keep the files in ressources/static and I also can't use a live reload server to serve the files. I have tried to enable "Refresh using native hooks or polling" in Eclipse, but still sometimes the files take awhile to refresh.
Is there a way to have the same behavior that using src/main/webapp folder gives?
Thanks in advance.
I end up using an workaround which was adding the config below to the pom.xml and runninng the app with mvn spring-boot:run instead of Eclipse's "Run as Spring Boot Application"
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<addResources>true</addResources>
</configuration>
</plugin>
If I understood your question correctly. You want to be able to change files outside of Eclipse and have those changes in server also?
If you change HTML/JS/CSS files outside of Eclipse you can sync files to {source_directory}\target\classes\static for instance update.
It worked for me when I was using the development server. Hope it works for you as well.
Related
I have a spring boot app as backend and using react as front end (both are in same project). I only have the one pom file for the backend and I run the spring app manually and then do a npm start on the frontend, all works fine. What I want to do now is deploy both backend and frontend and start them up automatically. Do I need another POM file for the front end or something which will execute npm etc? Front end was created with create-react-app and currently running on port 3000 ( "start": "react-scripts start" ), my backend running on port 8080 but would be deployed to an external tomcat server.
Do I need to add the following plugin:
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
and then some execution rules in the pom?
Any information is much appreciated.
Thanks
If you want to create war in spring boot, you need to add packaging as war and spring-boot-starter-tomcat should be <scope>provided</scope>. I think yes you need to add, please check the reference in the below url,
https://github.com/spring-guides/tut-react-and-spring-data-rest/blob/master/basic/pom.xml
Ref: https://spring.io/guides/tutorials/react-and-spring-data-rest/
<packaging>war</packaging>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
let me chip in and say something else. If you need a war as packaging, you can proceed as per Thangavel said. But I am a bit sceptical to go for a deployment like that on a production site.
Since you are using a front-end framework and spring as backend, I would suggest another way. Usually after doing a build of your front-end, you will use a http server like apache or nginx to deploy your build and then your war or jar for your spring boot project.
But if you want to keep both in the same project, you can do a build of your react project and it should be possible to import those JS files of your build in a thymeleaf or JSP view. Then you would only need to run the project on port 8080.
Here is an example for Angular. I am sure you can look for same in React.
How to include angular2/4 component in JSP page?
Please let me know how it goes.
If you want a good reference implementation you can generate a jhipster project and look at how the frontend plugin is used.
Is anyone having idea on status of tomcat8 Maven Plugin. Is it ready for use or not ? I can locate the repository for it here but could not find this plugin on apache site. I tried using it with same configuration as that of tomcat7-maven-plugin but it does not start my application.
Go to following link
https://mvnrepository.com/artifact/org.apache.tomcat.maven/tomcat8-maven-plugin/3.0-r1756463
copy paste the dependency tag
<dependency>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat8-maven-plugin</artifactId>
<version>3.0-r1756463</version>
But still if your pom file shows can't locate repository
click on the download link in above url and download jar file and past it in <your-home-directory>/.m2/repository/org/apache/tomcat/maven/tomcat8-maven-plugin/3.0-r1756463
In your IDE update maven project
tomcat maven plugin is only available for tomcat7, you can try spring boot which has an embedded tomcat8, it also provides other containers, like jetty
I am about to develop a web application. I will use this theme- http://startangular.com/product/flatlogic-angular-material-dashboard/ for admin panel. I already installed it on my local machine following the instructions. But this is my first time of installing a html theme like this using command lines (npm, gem and gulp).
I also noticed that all the AngularJS admin panel theme are has to be installed in that way. I mean using npm and other commands. Installation is fine. When I run this command
gulp serve
It opens the browser and show the admin panel. But the problem is I do not understand the project structure.
Admin panel is working when I serve gulp. But what I want is I just want to access without serving gulp. I mean I want to move it to xampp. Then integrate with a framework(PHP). So for now when I access directly, it is not working. What I want is I just want to have simple project, something like this
/project
========
/css
/js
/view
How can I build them into it? I mean using command lines. For now I have to serve gulp to access my project. To convert it manually, I checked the index.html and there are a lot of syntax commented I am not familiar with.
eg
<!-- build:css({.tmp/serve,src}) styles/vendor.css -->
<!-- bower:css -->
How can I convert the Angular theme into simple project to send to server for deployment? Can it be done from command lines?
Now my project is under
c:/xampp/htdocs/material_dashboard/angular-material-dashboard
When I access this
http://localhost/material_dashboard/angular-material-dashboard/src/
It shows nothing. Just white screen. No error in browser console as well.
When I access this
http://localhost/material_dashboard/angular-material-dashboard/.tmp/serve/
It is showing these errors.
All status code 404 returns.
How can I access the project without serving Gulp? From which url can I access?
Development server
Angular applications are mix of JavaScript, HTML, CSS and every paths is relative to the root of application - index.html.
In this case copy contents of dist folder. Copy whole dist folder and deploy it.
Development server just tries to simulate real one production server. If it is working on development - that one that is executed over gulp server it should also works on production environment.
Production environment
It is time to go straight with application. There are only two major steps
build it with gulp build (of course if you are using gulp and there is task like that)
copy content of the builded directory to production environment (that steps is also called deployment)
CORS issue?
AngularJS application and the backend should be executed (should run) on the same protocol, domain and port address to avoid CORS policy rules.
I am trying to execute the examples in Camel in action.
When I try to execute the "Spring DSL->Run As Local Camel Context" I am getting below error in JBoss Developer IDE:
Source locator does not exist: org.fusesource.ide.server.karaf.core.server.sourceLocator
Can any one help me?
I'm unaware of the build system of the project, but if it is Maven you may add following plugin to the pom.xml:
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>2.12.0</version>
<configuration>
<!--
the spring context file must be separate from the OSGi bundle, so we provide one here
-->
<fileApplicationContextUri>
src/main/resources/META-INF/spring/camel-context.xml
</fileApplicationContextUri>
</configuration>
</plugin>
where you can put the path to the camel-context.xml, and then you can run
mvn camel:run
to test the routes.
Hope I've helped you.
I had updated the plugin for fuse integration in Jboss IDE and it is working fine now.
Thanks a lot for your response.
I am developing a Google Appengine Java application and I am facing a major challenge testing with the local dev server. I dumped the Eclipse tools cause I'm more flexible with Netbeans and
I am using Appengine Maven plugin for my development.
This is my sample project structure :
myapp
module-endpoints
module-web
module-ear
pom.xml
The application works when I build with mvn clean install on the root folder(myapp) and also when I use the mvn appengine:devserver command to run the module-ear application, however I can't seem to access the cloud endpoints via http://localhost:8080/_ah/api. I can only access the endpoint's API via the dynamically issued port when I access it via the admin console http://localhost:8080/_ah/admin.
The issue with this is that when testing cloud-endpoint Javascript client on the module-web project according to tutorials I am supposed to use localhost:8080/_ah/api as my url to test. Am I missing something?
If the question is still actual you could always update your pom.xml with flags so that the ports of all your modules are defined:
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
<configuration>
<port>8080</port>
<jvmFlags>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n</jvmFlag>
<jvmFlag>-Dcom.google.appengine.devappserver_module.mymodule2.port=9090</jvmFlag>
</jvmFlags>
<disableUpdateCheck>true</disableUpdateCheck>
</configuration>
</plugin>
Then you could use localhost:9090/_ah/api/explorer to test your APIs
If you have several modules deployed, you need to update your maven app engine launcher setup to recognize the different modules. See the modules sample Java app at https://github.com/GoogleCloudPlatform/appengine-modules-sample-java.
If you've already done that, then a dispatch.xml file will tell app engine how to route requests: https://cloud.google.com/appengine/docs/java/modules/routing
It worked when I made the endpoints project the default module.
dispatch.xml is ignored on devserver, the documentation states the following.
Dispatch files
All dispatch files are ignored when running the development server.
The only way to target instances is through their ports.
This means that only the default module will be reachable at the configured port (typically 8888 or 8080). I have just tested it with app engine 1.9.25 and it does not work, so no improvement has been made.
On the other hand you can always refer to the module by its port. The module's location is logged in the console when the application starts, you will see something like:
INFO: Module instance module2-auto is running at http://localhost:37251/
In my case this was useless since I was expecting to make AJAX requests to different modules by using the same host (but different urls). For instance: