无法在Springboot中调试控制器

时间:2019-09-09 10:46:52

标签: rest spring-boot debugging model-view-controller

我正在尝试在本地计算机上调试代码。我以调试方法启动了我的应用程序,并通过浏览器发送了一个请求。由于某种原因,它不会到达控制器中的断点,但是会到达控制器中使用的服务类中的断点。可能是什么原因呢?

另外,当我以调试模式启动应用程序时,我看到两个终端都打开了。

我的控制器是:

   public class MyController{

        private final MyService myService;

        @GetMapping(value = "/{id}")
        @ApiOperation("Returns by identifier")
        public ResponseEntity<MyDTO> getById(@PathVariable("id") final Long id) {
            val myObj= myService.findById(id); // here is breakpoint
            return ResponseEntity.ok(myObj);
        }
    }

我的服务等级是

@Service
@RequiredArgsConstructor
public class MyServiceImp implements MyService{

  private final ModelMapper modelMapper;
    private final MyRepository myRepository;


  @Override
    @Transactional(readOnly = true)
    public MyDTO findById(final Long id) {
        return myRepository.findById(id)
                .map(myObj-> modelMapper.map(myObj, MyDTO.class))
                .orElseThrow(() -> new QuestionNotFoundException(id));
    }
}

我的pom文件是:

  <dependencies>
    <dependency>
      <groupId>org.webjars.bowergithub.vaadin</groupId>
      <artifactId>vaadin-usage-statistics</artifactId>
      <version>1.0.0-optout</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>flow-server-production-mode</artifactId>
      <version>1.2.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-websocket</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>vaadin-spring-boot-starter</artifactId>
      <version>13.0.8</version>
    </dependency>
    <dependency>
      <groupId>org.modelmapper</groupId>
      <artifactId>modelmapper</artifactId>
      <version>2.3.4</version>
    </dependency>
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger2</artifactId>
      <version>2.9.2</version>
    </dependency>
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger-ui</artifactId>
      <version>2.9.2</version>
    </dependency>
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-bean-validators</artifactId>
      <version>2.9.2</version>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.1.5.RELEASE</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

0 个答案:

没有答案