I am trying to create a RestFul web service using Spring, which retrieves data from the mongoDB collection and serves it for the client. To build the service, I followed this spring.io tutorial . Everything went well, I can access the data from mongoDB and find it for the name of the data structure. The problems started when I tried to manage requests from my client, I get a classic error with violations in the same area.
No header "Access-Control-Allow-Origin" is present in the requested resource.
The project is extremely simple, consists of three classes:
Frames.java
@Id
private String Id;
private String frameName;
private ArrayList<String> frameElements;
public String getId() {
return Id;
}
public String getFrameName() {
return frameName;
}
public ArrayList<String> getFrameElements() {
return frameElements;
}
FrameRestFulServiceApplication.java
@SpringBootApplication
public class FrameRestFulServiceApplication {
public static void main(String[] args) {
SpringApplication.run(FrameRestFulServiceApplication.class, args);
}
}
FramesRepository.java
@RepositoryRestResource(collectionResourceRel = "frames", path = "frames")
public interface FramesRepository extends MongoRepository<Frames, String>{
List<Frames> findByFrameNameLike(@Param("frameName") String frameName);
List<Frames> findByFrameName(@Param("frameName") String frameName);
}
, . , ...