Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用JHipster单独或单独结束应用程序:_Java_Angularjs_Authentication_Jwt_Jhipster - Fatal编程技术网

Java 使用JHipster单独或单独结束应用程序:

Java 使用JHipster单独或单独结束应用程序:,java,angularjs,authentication,jwt,jhipster,Java,Angularjs,Authentication,Jwt,Jhipster,为前端和后端应用程序创建两个目录 mkdir前端 mkdir后端 将目录更改为frontend,并运行JHipster命令仅创建frontend模块 cd前端 jhipster--跳过服务器--db=sql--auth=jwt 如果一切正常,请运行npm start命令来运行前端应用程序 我将mysql用于db,JWT用于auth,如果您想使用websocket,请添加:“--websocket=SpringWebSocket” 现在,将您的目录更改为后端,并运行JHipster命令来

为前端和后端应用程序创建两个目录

  • mkdir前端
  • mkdir后端
  • 将目录更改为frontend,并运行JHipster命令仅创建frontend模块

    • cd前端
    • jhipster--跳过服务器--db=sql--auth=jwt
    • 如果一切正常,请运行npm start命令来运行前端应用程序
    我将mysql用于db,JWT用于auth,如果您想使用websocket,请添加:“--websocket=SpringWebSocket”

  • 现在,将您的目录更改为后端,并运行JHipster命令来创建后端模块

    • cd//因为我们目前正在备份后端目录
    • cd后端
    • jhipster—跳过客户端
    • 在运行spring引导应用程序时运行后端应用程序

  • 现在,您的前端和后端应用程序分别运行,前端通过REST API调用与后端应用程序协调。

    这只是一个想法,但您可以再次检查后端是否能够处理有效凭据。看到了吗?丹尼尔:不幸的是,没有。在我问了这个问题后,我很快就停止了与杰普斯特的游戏。@musa我下面的回答帮助了其他一些人,也是我解决问题的方法。请查看并考虑将其标记为已接受的答案。现在您想在PROD上部署它,您将创建一个WAR /jar部署。您需要在项目中更改哪些文件?对于部署,更好的方法是分别部署前端和后端。tomcat上的后端和apache上的前端。谢谢。但我想在谷歌应用程序引擎上部署。那么我应该为它制作两个不同的项目吗?如何将前端应用程序与后端应用程序连接起来(是的,我可以使用rest调用,但是…),我得到服务器API URL:
    Welcome to the JHipster Generator
    
    ? (1/13) What is the base name of your application? jhipster
    ? (2/13) What is your default Java package name? com.mycompany.myapp
    ? (3/13) Do you want to use Java 8? Yes (use Java 8)
    ? (4/13) Which *type* of authentication would you like to use? Token-based authentication (stateless, with a token)
    ? (5/13) Which *type* of database would you like to use? SQL (H2, MySQL, PostgreSQL)
    ? (6/13) Which *production* database would you like to use? MySQL
    ? (7/13) Which *development* database would you like to use? H2 in-memory with Web console
    ? (8/13) Do you want to use Hibernate 2nd level cache? Yes, with ehcache (local cache, for a single node)
    ? (9/13) Do you want to use clustered HTTP sessions? No
    ? (10/13) Do you want to use WebSockets? No
    ? (11/13) Would you like to use Maven or Gradle for building the backend? Maven (recommended)
    ? (12/13) Would you like to use Grunt or Gulp.js for building the frontend? Grunt (recommended)
    ? (13/13) Would you like to use the Compass CSS Authoring Framework? No
    
    ...
    
    I'm all done. Running bower install & npm install for you
    ^C
    
    [DEBUG] com.mycompany.myapp.security.Http401UnauthorizedEntryPoint - Pre-authenticated entry point called. Rejecting access
    
    XMLHttpRequest cannot load http://localhost:8080/api/authenticate. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.
    
    .antMatchers(org.springframework.http.HttpMethod.OPTIONS, "/api/**").permitAll()
    
    response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
    response.setHeader("Access-Control-Max-Age", "86400"); // 24 Hours
    response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, x-auth-token");
    
       <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-catalina</artifactId>
            <version>8.0.15</version>
            <scope>provided</scope>
        </dependency>
    
    private void initCorsFilter(ServletContext servletContext, EnumSet<DispatcherType> disps) {
            log.debug("Registering CORS Filter");
            FilterRegistration.Dynamic corsFilter = servletContext.addFilter("corsFilter", new CorsFilter());
            Map<String, String> parameters = new HashMap<>();
            parameters.put("cors.allowed.headers", "Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization");
            parameters.put("cors.allowed.methods", "GET,POST,HEAD,OPTIONS,PUT,DELETE");
            corsFilter.setInitParameters(parameters);
            corsFilter.addMappingForUrlPatterns(disps, false, "/*");
            corsFilter.setAsyncSupported(true);
        }
    
    ...
    initCorsFilter(servletContext, disps);
    ...
    
    var links = {};
    if (!angular.isObject()) {
        // CORS OPTIONS responses
        return links;
    }
    
    if (header.length == 0) {
        throw new Error("input must not be of zero length");
    }
    
    // Split parts by comma
    var parts = header.split(','); 
    
    ...