在sts spring boot中运行spring项目中的问题

时间:2018-12-02 12:48:51

标签: java spring spring-boot

我在sts spring工具套件中运行spring boot应用程序时收到以下警告

>WARNING: An illegal reflective access operation has occurred
>WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/home/imart/.m2/repository/org/springframework/spring-core/5.0.7.RELEASE/spring-core-5.0.7.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
>WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
>WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
>WARNING: All illegal access operations will be denied in a future release

我的代码在下面。

package com.search;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Hello world!
 *
 */
@RestController
@EnableAutoConfiguration
public class App 
{
    @RequestMapping("/tools/related_info")

    public String index() {
        return "Hello How are you";
    }

    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

我的pom.xml为

<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>com.indiamart</groupId>
  <artifactId>tools</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>tools</name>
  <url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
</parent>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
  </dependencies>
</project>

1 个答案:

答案 0 :(得分:0)

Java 11不支持Spring Boot 2.0.x和Spring Framework5.0.x。如果要使用Java 11,则应升级到Spring Boot2.1.x。这还将升级到Spring Framework 5.1.x。