I am trying to add a CORS Filter to my Play Framework REST API. I added a Filters class, as per the documentation , however it cannot seem to find the following package at all, I have searched high and low and no luck:
import play.filters.cors.CORSFilter;
And the Filter class:
import play.api.mvc.EssentialFilter;
import play.filters.cors.CORSFilter;
import play.http.HttpFilters;
import javax.inject.Inject;
public class Filters implements HttpFilters {
@Inject
CORSFilter corsFilter;
public EssentialFilter[] filters() {
return new EssentialFilter[] { corsFilter };
}
}
build.sbt:
libraryDependencies ++= Seq(
javaJpa,
filters,
"org.hibernate" % "hibernate-entitymanager" % "4.3.7.Final",
"org.projectlombok" % "lombok-maven" % "1.16.6.1",
"org.postgresql" % "postgresql" % "9.4.1207.jre7",
"org.springframework.data" % "spring-data-jpa" % "1.9.2.RELEASE",
"org.mindrot" % "jbcrypt" % "0.3m"
)
Where is this package?
Use activator eclipse
command in terminal as like activator run
.
Its resolve my problem, hope its also works for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.