1

I'm new to Angularjs and i'm trying to run first angular program with Spring. I downloaded the code from here: http://javahonk.com/spring-mvc-angularjs-integration/. Imported it as a maven project. Downloaded JSDT and AngualrJs plugin from eclipse marketplace but it's still not running. There is no error message. I'm running this on tomcat 7. What am I missing?

Any help would be appreciated?

zydexo
  • 63
  • 5
  • 12

2 Answers2

2

I'm not a Eclipse user. so I have no idea for that. But you can use nodejs as a static server. it is explained here

1) Install nodejs for your OS

2) Run this command in a terminal (console)

> npm install http-server -g

3) Start server

> cd /path/to/your/project
> http-server -o --cors 

Now you can access your project from browser http://localhost:8080/yourfile.html

Work in Eclipse and just refresh page on browser to see changes.

Community
  • 1
  • 1
bhdrk
  • 2,991
  • 23
  • 18
  • I have been using node earlier. But now that I want to integrate with Spring and mysql and web services. Would this still work? – zydexo Nov 09 '14 at 19:22
  • yes you can work with this in development stage. if you want to use angularjs to integrate with restful services (probably bestway) this strategy shortly named as single or one page app architect. in this case your frontend and backend run on different servers. frontend usually just stores static files like html, css, js and images. so should be a http server to serve these files. nodejs is a good choose in development. in production there are more alternative to nodejs like nginx, apache and so on – bhdrk Nov 09 '14 at 20:59
  • So if I'm creating a JSon object in Spring, which is being fetched from mysql server and want to fetch that in angularJS controller to show it in my html. Wouldn't that make two different calls on two different servers and ultimately slow the process down? Or am i missing something? Or is that normal working with angularJS? – zydexo Nov 10 '14 at 05:49
0

If you are working on a Spring Application within Eclipse IDE, your best alternative would be to start you appliction using an embedded Application Server (Best I would recommand are Jetty or Tomcat if you ain't need EE level components). You can follow this link, which holds basic steps for adding a new Application Server within Eclipse IDE.

Once you have added a new application server, you can deploy your application in it then launch it and you should have your applcation reachable at http://localhost:8080/SpringMVCAngularJS.

A good alternative when using Maven as a build tool, is using an embedded AS plugin such as Tomcat7 Plugin or Jetty Plugin. This plugin will provide the ability to start your applcation using the Maven different goals (which does not require adding a new AS into Eclipse IDE). I've pushed a sample module based on the tutorial you mentioned. YOu can test the above described plugin as follows in a *nix shell (You may need to setup git if not already done):

git clone https://github.com/tmarwen/stackoverflow-showcase.git
cd stackoverflow-showcase/springmvc-angularjs
mvn tomcat7:run
tmarwen
  • 11,491
  • 4
  • 35
  • 54
  • Thanks for the help but I solved it earlier and it was running. Sorry, i don't remember how I solved. I've been consumed with trying to integrate angularJS with spring. Now I have integrated the whole angular app with spring and trying to make that work. – zydexo Nov 11 '14 at 15:09
  • You may need to try the provided trick in respect of community efforts and it it fits your need you can then accept it or even upvote it :) – tmarwen Nov 11 '14 at 16:50
  • Sorry I didn't get back to you earlier but I had tried that earlier but I Found out that my problem was in my understanding of spring's dependency injections. Again thanks for the help! And I don't mean any disrespect! – zydexo Nov 19 '14 at 19:30