小编Man*_*Pap的帖子

Heroku 无法部署 Java 11 Spring Boot App

我正在尝试使用 Java 版本 11.0.1 在 Heroku 上部署 Spring Boot 应用程序。错误:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project my-project: Fatal error compiling: invalid target release: 11 -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

经过大量研究,我找到了https://github.com/heroku/heroku-buildpack-java。我创建了system.properties具有多种变体的文件,例如:

  • java.runtime.version=11
  • java.runtime.version=11.0.1

但是,部署时仍然出现相同的错误。Spring Boot 和 Project java 版本设置为 11。 在此处输入图片说明

Windows 上的 java 版本也在 11.0.1 上设置 在此处输入图片说明

并且在部署时 在此处输入图片说明

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>net.manolispapadimitriou</groupId>
    <artifactId>my-project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>my-project</name>
    <description>My Project</description>


    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties> …
Run Code Online (Sandbox Code Playgroud)

java spring heroku fatal-error spring-boot

15
推荐指数
1
解决办法
8582
查看次数

将JWT令牌传递给SockJS

当SockJS发生握手时,我需要发送令牌。我尝试了许多建议的实现,但是调用了相同的异常

java.lang.IllegalArgumentException: JWT String argument cannot be null or empty.
Run Code Online (Sandbox Code Playgroud)

在后端 WebSocketConfig

@Configuration
@EnableWebSocketMessageBroker
@CrossOrigin
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableSimpleBroker("/socket");
        config.setApplicationDestinationPrefixes("/app");
    }

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/websocket").withSockJS();
    }
}
Run Code Online (Sandbox Code Playgroud)

尝试与套接字建立连接的函数。普通的javascript。

function connect() {
    var socket = new SockJS('http://localhost:8889/websocket',
             null,
            {
                transports: ['xhr-streaming'], 
                headers: {'Authorization': 'Bearer eyJhbGciOiJIUzUxMiJ9...' }
            });
    stompClient = Stomp.over(socket);
    stompClient.connect({},function (frame) {
        setConnected(true);
        console.log('Connected: ' + frame);
        stompClient.subscribe('/socket/event', function (greeting) {
            showGreeting(JSON.parse(greeting.body).content);
        });
    });
}
Run Code Online (Sandbox Code Playgroud)

问题出在握手上,这些标头似乎未正确传递令牌。我已经尝试过多种握手方式,但是我找不到正确的方式。

在握手之后尝试使用标头之前,我从这里得到了实现的想法,但我发现它立即需要令牌。

https://github.com/sockjs/sockjs-client/issues/196#issuecomment-61469141 …

javascript java websocket sockjs spring-boot

9
推荐指数
1
解决办法
530
查看次数

Spring Boot JWT CORS 与 Angular 6

我在 Spring Boot 应用程序中使用 JWT。当我尝试从 Angular 6 客户端登录时,出现 CORS 错误

Access to XMLHttpRequest at 'http://localhost:8082/login' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Run Code Online (Sandbox Code Playgroud)

我尝试添加标头"Access-Control-Allow-Origin,我什至尝试使用一些 chrome 扩展,但仍然无法绕过 CORS。我可以使用 Postman 访问登录 API 并获取令牌。

Spring Boot 类

WebSecurityConfig.java

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    private UserDetailsService userDetailsService;
    private BCryptPasswordEncoder bCryptPasswordEncoder;

    public WebSecurityConfig(@Qualifier("customUserDetailsService") UserDetailsService userDetailsService, BCryptPasswordEncoder bCryptPasswordEncoder) {
        this.userDetailsService = userDetailsService;
        this.bCryptPasswordEncoder = bCryptPasswordEncoder; …
Run Code Online (Sandbox Code Playgroud)

java cors jwt spring-boot angular

6
推荐指数
2
解决办法
7884
查看次数

按位置获取列表元素

我想给一个数字并返回这个位置的元素.列出 lab = (R K K K K)我想知道(position 1 lab)在lisp上是否存在这样的东西.就像C return lab[1].

lisp common-lisp

5
推荐指数
2
解决办法
6688
查看次数

POST上的Angular 6 HttpErrorResponse状态为200

随着我的角6的客户我访问的http://localhost:8082/login发送usernamepassword并返回一个令牌。这是错误在此处输入图片说明 请注意,下面error:是我想要的令牌。

这就是邮递员的样子 在此处输入图片说明

这是我在Angular上使用的函数,用于使用给定的用户名和密码获取令牌

validateUser(user:User){


    var reqHeader = new HttpHeaders({ 'Content-Type': 'application/json','No-Auth':'True' });



    return this.httpClient.post<User>(this.apiURL + '/login',user,{headers:reqHeader});
  }
Run Code Online (Sandbox Code Playgroud)

我只想返回令牌,就像在邮递员中一样。我试过了,toPromise()但是有更多错误。

api post angular

2
推荐指数
1
解决办法
1522
查看次数