1

I'm using eclipse to build angular application (my first application), at the beginning I created my project via New->Angular Project (I have plugins installed) but later on I was asked to use a Dynamic Web Project (with WebContent Folder) and I was wondering what is the best way of doing it!

What I tried is creating a Dynamic Web Project, then from inside the folder of that project to create a new angular2 site (in parallel to Java resources using angular-cli: > ng new Angular Resources). But I have issues with that and I'm not sure that am doing it the right way: enter image description here

The reason why I need this is because am going to use shiro for users authentication and I need to develop a RestApi as well that will be part of the same war. Example for such a project that was done with angularJs (angular1):

enter image description here

Even if I locate the angular folder under WebConent (like what was done here), I'll still have errors (JSon, DTD, HTMl) in node_modules.

I found something similar to what I'm looking for, and I'm trying to do it works for me as well: https://github.com/Angular2Guy/Angular2AndJavaEE

how to integrate Angular 2 + Java Maven Web Application

Gowtham Shiva
  • 3,802
  • 2
  • 11
  • 27
zbeedatm
  • 601
  • 1
  • 15
  • 39
  • Just one question: Why do you want to use Angular 2 when there is already version 5?? https://blog.angular.io/version-5-0-0-of-angular-now-available-37e414935ced – FranzHuber23 Nov 04 '17 at 08:20
  • As I know the version stepped over 2.4 and announced about angular 4 which is not even a major upgrade (the router library was changed)... but will consider it. Thanks – zbeedatm Nov 04 '17 at 12:00

1 Answers1

0

I'm trying something different. By using the maven-war-plugin as below:

<plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <warSourceDirectory>WebContent/WEB-INF</warSourceDirectory>
                <failOnMissingWebXml>true</failOnMissingWebXml>
            </configuration>
        </plugin>

And creating a WebContent folder manually in parallel to my pom.xml

web.xml is located under WEB-INF and it contains:

<servlet-name>rest</servlet-name>
    <servlet-class>
    org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>


<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/management/*</url-pattern>

But still not getting my API functioning and working with the RestController that I built for that purpose.

zbeedatm
  • 601
  • 1
  • 15
  • 39