26
Окт
2016

Ошибка при запуске приложения spring-boot

Имею такой pom:

<?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>com.1sttech</groupId>
    <artifactId>SpringREST</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SpringREST</name>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Запускаю в Intelli IDE все работает. Запускаю в NetBeans получаю ошибки:

--- exec-maven-plugin:1.2.1:exec (default-cli) @ SpringREST ---
2016-10-26 17:32:01.303 ERROR 12248 --- [  restartedMain] o.s.b.c.FileEncodingApplicationListener  : System property 'file.encoding' is currently 'Cp1251'. It should be 'utf-8' (as defined in 'spring.mandatoryFileEncoding').
2016-10-26 17:32:01.307 ERROR 12248 --- [  restartedMain] o.s.b.c.FileEncodingApplicationListener  : Environment variable LANG is 'null'. You could use a locale setting that matches encoding='utf-8'.
2016-10-26 17:32:01.307 ERROR 12248 --- [  restartedMain] o.s.b.c.FileEncodingApplicationListener  : Environment variable LC_ALL is 'null'. You could use a locale setting that matches encoding='utf-8'.
2016-10-26 17:32:01.307  WARN 12248 --- [  restartedMain] o.s.boot.SpringApplication               : Error handling failed (no error message)
2016-10-26 17:32:01.312 ERROR 12248 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed
java.lang.IllegalStateException: The Java Virtual Machine has not been configured to use the desired default character encoding (utf-8).
...
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project SpringREST: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project SpringREST: Command execution failed.

Запускаю с консоли mvn spring-boot:run получаю ошибки:

[INFO] --- spring-boot-maven-plugin:1.4.1.RELEASE:run (default-cli) @ SpringREST ---
[INFO] Attaching agents: []
2016-10-26 17:16:22.213 ERROR 13208 --- [  restartedMain] o.s.b.c.FileEncodingApplicationListener  : System property 'file.encoding' is currently 'Cp1251'. It should be 'utf-8' (as defined in 'spring.mandatoryFileEncoding').
2016-10-26 17:16:22.218 ERROR 13208 --- [  restartedMain] o.s.b.c.FileEncodingApplicationListener  : Environment variable LANG is 'null'. You could use a locale setting that matches encoding='utf-8'.
2016-10-26 17:16:22.221 ERROR 13208 --- [  restartedMain] o.s.b.c.FileEncodingApplicationListener  : Environment variable LC_ALL is 'null'. You could use a locale setting that matches encoding='utf-8'.
2016-10-26 17:16:22.221  WARN 13208 --- [  restartedMain] o.s.boot.SpringApplication               : Error handling failed (no error message)
2016-10-26 17:16:22.226 ERROR 13208 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed

java.lang.IllegalStateException: The Java Virtual Machine has not been configured to use the desired default character encoding (utf-8).
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.1.RELEASE:run (default-cli) on project SpringREST: Could not exec java: Application finished with exit code: 1 -> [Help 1]

Я так понял проблема в кодировке и как это исправить? System property 'file.encoding' is currently 'Cp1251'. И главное почему с Intelli IDE работает?

Источник: https://ru.stackoverflow.com/questions/583119/%D0%9E%D1%88%D0%B8%D0%B1%D0%BA%D0%B0-%D0%BF%D1%80%D0%B8-%D0%B7%D0%B0%D0%BF%D1%83%D1%81%D0%BA%D0%B5-%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D1%8F-spring-boot

Share

Тебе может это понравится...