0

I am learning spring boot and spring security with angularjs.

previously I use CDN to load angular in my html, everything just fine.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-route.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-messages.js"></script>

but many people said using bower is better so I want to give it a try. I've installed bower, set the diretory to resources/static/bower_components, install the dependencies, and change the script.

<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-messages/angular-messages.js"></script>

but, when I load the html, it said failed 404. When I tried it on the web, Whitelabel Error Page error occured.

As I know, everything in resources/static will be publicly available? Why I cannot access it?

--EDIT--

I am trying a solution from Not loading static Resources in Spring boot, Thymeleaf and AngularJs app, but still failed.

@Configuration
public class WebConfig extends WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/bower_components/**")
                .addResourceLocations(classpath:"/static/bower_components/");
    }
}
Community
  • 1
  • 1
Disp Hay
  • 1,341
  • 3
  • 14
  • 20

1 Answers1

1

I've solved it. The solution is to delete your project from Package Explorer in Eclipse and import it again from File->Import.

A simpler solution is to refresh your project in Eclipse (Right click on your project -> choose Refresh (F5))

Disp Hay
  • 1,341
  • 3
  • 14
  • 20