Good I am beginning with the web service, create one in java, which I want to connect with angular2, but it throws me an error.
The problem is because there is a browser protection to consume in other sites, whether different web or domain there are ways to enable it but the easiest thing is to proxy from either the constructor that you are using angular-cli or Webpack of such way that is Localhost: 888 / angular Y Localhost: 888 / javaapi and that will allow you to do the browser Good luck
It is a problem of configuration of the headers. To solve it you have to look for the .htaccess of your server (the API server) and include this line:
Header set Access-Control-Allow-Origin "*"