JHipster从8.1.0升级失败

问题描述 投票:0回答:1

我的JHipster项目是在8.0.0版本上创建的,然后成功升级到8.1.0版本。之后,当我尝试升级到8.2.1或8.3.0时出现错误,并出现以下错误。

   create src\test\java\com\pccw\hktms\mp\config\RedisTestContainersSpringContextCustomizerFactory.java
ERROR! ERROR! Error parsing file src\main\java\com\pccw\hktms\mp\config\SecurityConfiguration.java: Error: Sad sad panda, parsing errors detected in line: 42, column: 9!
Expecting --> ';' <-- but found --> 'return' <--!
        ->compilationUnit
        ->ordinaryCompilationUnit
        ->typeDeclaration
        ->classDeclaration
        ->normalClassDeclaration
        ->classBody
        ->classBodyDeclaration
        ->classMemberDeclaration
        ->methodDeclaration
        ->methodBody
        ->block
        ->blockStatements
        ->blockStatement
        ->statement
        ->statementWithoutTrailingSubstatement
        ->expressionStatement at package com.pccw.hktms.mp.config;

import com.pccw.hktms.mp.security.*;
import tech.jhipster.config.JHipsterProperties;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;


@Configuration
@EnableMethodSecurity(securedEnabled = true)
public class SecurityConfiguration {

    private final JHipsterProperties jHipsterProperties;

    public SecurityConfiguration( JHipsterProperties jHipsterProperties) {
        this.jHipsterProperties = jHipsterProperties;
    }

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http, MvcRequestMatcher.Builder mvc) throws Exception {
        http
            .csrf(csrf -> csrf
                .disable())
            .authorizeHttpRequests(authz ->
                // prettier-ignore
                authz
                    .requestMatchers(mvc.pattern("/api/authenticate")).permitAll()
                    .requestMatchers(mvc.pattern("/api/admin/**")).hasAuthority(AuthoritiesConstants.ADMIN)
                    .requestMatchers(mvc.pattern("/api/**")).authenticated()
                    .requestMatchers(mvc.pattern("/v3/api-docs/**")).hasAuthority(AuthoritiesConstants.ADMIN)
                    .requestMatchers(mvc.pattern("/management/health")).permitAll()
                    .requestMatchers(mvc.pattern("/management/health/**")).permitAll()
                    .requestMatchers(mvc.pattern("/management/info")).permitAll()
                    .requestMatchers(mvc.pattern("/management/prometheus")).permitAll()
                    .requestMatchers(mvc.pattern("/management/**")).hasAuthority(AuthoritiesConstants.ADMIN))
        return http.build();
    }

    @Bean
    MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
        return new MvcRequestMatcher.Builder(introspector);
    }
}
    at file:///C:/Users/02007425/IdeaProjects/mp-api/node_modules/generator-jhipster/dist/generators/bootstrap/support/java-unused-imports-transform.mjs:20:27
    at Transform.<anonymous> (file:///C:/Users/02007425/IdeaProjects/mp-api/node_modules/@yeoman/transform/dist/transform.js:42:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Transform.transform [as _transform] (file:///C:/Users/02007425/IdeaProjects/mp-api/node_modules/@yeoman/transform/dist/transform.js:16:37)
ERROR! An error occured while running jhipster:upgrade#prepareUpgradeBranch
ERROR! ERROR! Command failed with exit code 1: npx --no jhipster --force --skip-install --skip-git --ignore-errors --no-insight --skip-checks
Error: Command failed with exit code 1: npx --no jhipster --force --skip-install --skip-git --ignore-errors --no-insight --skip-checks
    at makeError (file:///C:/Program%20Files/nodejs/node_modules/generator-jhipster/node_modules/execa/lib/error.js:60:11)
    at handlePromise (file:///C:/Program%20Files/nodejs/node_modules/generator-jhipster/node_modules/execa/index.js:124:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async UpgradeGenerator.prepareUpgradeBranch (file:///C:/Program%20Files/nodejs/node_modules/generator-jhipster/dist/generators/upgrade/generator.js:168:21)
    at async UpgradeGenerator.executeTask (file:///C:/Program%20Files/nodejs/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:244:13)
    at async runLoop.add.once (file:///C:/Program%20Files/nodejs/node_modules/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:395:17) {
  shortMessage: 'Command failed with exit code 1: npx --no jhipster --force --skip-install --skip-git --ignore-errors --no-insight --skip-checks',

显然,行尾缺少

;
.requestMatchers(mvc.pattern("/management/**")).hasAuthority(AuthoritiesConstants.ADMIN))

我已尝试将

npm
node
更新到最新版本。但同样的问题仍然存在。

>npm doctor
Check                      Value   Recommendation/Notes
npm ping                   ok
npm -v                     ok      current: v10.5.2, latest: v10.5.2
node -v                    ok      current: v20.12.2, recommended: v20.12.2
npm config get registry    ok      using default registry (https://registry.npmjs.org/)
git executable in PATH     ok      C:\Program Files\Git\cmd\git.EXE
global bin folder in PATH  ok      C:\Program Files\nodejs
java jhipster upgrade
1个回答
0
投票

请尝试JHipster Migrate 蓝图,看看它是否适合您:

npm install -g generator-jhipster-migrate
jhipster-migrate
© www.soinside.com 2019 - 2024. All rights reserved.