简体   繁体   English

尝试运行示例 Spring Boot 应用程序时出现格式错误的 url excpetion

[英]Malformed url excpetion while trying to run sample spring boot app

I'm trying to run sample Spring Boot application for the first time on Spring Tool Suite 4 Version: 4.8.1.RELEASE and JDK我第一次尝试在 Spring Tool Suite 4 版本:4.8.1.RELEASE 和 JDK 上运行示例 Spring Boot 应用程序

java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) Client VM (build 25.251-b08, mixed mode)

When try to run sample application as Spring Boot, it gives the following exception当尝试将示例应用程序作为 Spring Boot 运行时,它给出了以下异常

Picked up JAVA_TOOL_OPTIONS: -Djdk.lang.Process.allowAmbiguousCommands=true
Error: Exception thrown by the agent : java.net.MalformedURLException: Service URL contains non-ASCII character 0x666
jdk.internal.agent.AgentConfigurationError: java.net.MalformedURLException: Service URL contains non-ASCII character 0x666
    at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:493)
    at jdk.management.agent/jdk.internal.agent.Agent.startAgent(Agent.java:447)
    at jdk.management.agent/jdk.internal.agent.Agent.startAgent(Agent.java:599)
Caused by: java.net.MalformedURLException: Service URL contains non-ASCII character 0x666
    at java.management/javax.management.remote.JMXServiceURL.<init>(JMXServiceURL.java:157)
    at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.exportMBeanServer(ConnectorBootstrap.java:870)
    at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:481)
    ... 2 more

This the code for the test class这是测试类的代码

package com.apress.ravi;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class UserRegisterationSystemApplication {

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

}

and this is the code for POM.xml file这是 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.apress.ravi</groupId>
    <artifactId>UserRegisterationSystem</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>UserRegisterationSystem</name>
    <description>User Registeration System For Crud Operation</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

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

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

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

</project>

usersDTO.java用户DTO.java

package com.apress.ravi.dto;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="Users")
public class UsersDTO {

        @Id
        @GeneratedValue
        @Column(name = "USER_ID")
        private Long id;

        @Column(name = "NAME")
        private String name;

        @Column(name = "ADDRESS")
        private String address;

        @Column(name = "EMAIL")
        private String email;

        // Getters and Setters methods
}

interface UserJpaRepository接口 UserJpaRepository

package com.apress.ravi.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import com.apress.ravi.dto.UsersDTO;

@Repository
public interface UserJpaRepository extends JpaRepository<UsersDTO, Long> {

        UsersDTO findByName(String name);
}

UserRegistrationRestController package com.apress.ravi.Rest; UserRegistrationRestController 包 com.apress.ravi.Rest;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.apress.ravi.dto.UsersDTO;
import com.apress.ravi.repository.UserJpaRepository;

@RestController
@RequestMapping("/api/user")
public class UserRegistrationRestController {
        public static final Logger logger =
                LoggerFactory.getLogger(UserRegistrationRestController.class);

        private UserJpaRepository userJpaRepository;

        @Autowired
        public void setUserJpaRepository(UserJpaRepository userJpaRepository) {
                this.userJpaRepository = userJpaRepository;
        }        
        
        @GetMapping("/")
        public ResponseEntity<List<UsersDTO>> listAllUsers() {
                List<UsersDTO> users = userJpaRepository.findAll();
                return new ResponseEntity<List<UsersDTO>>(users, HttpStatus.OK);
        }
}

UserRegisterationSystemApplicationTests package com.apress.ravi; UserRegisterationSystemApplicationTests 包 com.apress.ravi;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class UserRegisterationSystemApplicationTests {

    @Test
    void contextLoads() {
    }

}

It might be that the host name of your computer contains a non-ascii char which spring is using in the JMX URL.可能是您计算机的主机名包含 spring 在 JMX URL 中使用的非 ascii 字符。 Disable JMX monitoring if you don't need it using the following property如果您不需要使用以下属性禁用 JMX 监控

spring.jmx.enabled=false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试访问资源URL时在Spring Boot中使用Http 404 - Http 404 in Spring Boot while trying to access resource url Spring Boot App未运行 - Spring Boot App not run JPA Sample Spring Boot应用程序抛出BeanCreationException - JPA Sample Spring Boot app throws BeanCreationException 运行 Spring 启动应用程序时出现与 bean 创建相关的错误 - Getting error related with bean creation while run Spring Boot app 尝试在App Engine上运行时,示例项目“ hello-world”项目显示ERROR - Sample project “hello-world” project is showing ERROR while trying to run on App engine spring-无法在tomcat上运行spring boot应用 - spring - unable to run spring boot app on tomcat 尝试使用 dynamodb 和 graphql 运行我的 Spring Boot 应用程序时,我不断收到此 @bean 错误 - I keep getting this @bean error when trying to run my spring boot app with dynamodb and graphql 尝试运行Spring Boot应用程序时出错。 创建名称为bean的错误 - Error trying to run Spring boot app. Error creating bean with name Gradle不适用于Spring Boot样本应用程序。 为什么不? - Gradle does not work with spring boot sample app. Why not? 如何在 Spring 引导项目中的应用启动时创建示例实体? - How to create sample entities on app startup in a Spring Boot project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM