Исключение при оценке выражения SpringEL после обновления SpringBoot с 2.0.6.RELEASE до 2.1.0.RELEASE - PullRequest
0 голосов
/ 01 ноября 2018

У меня было приложение SpringBoot с этим pom.xml:

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

<!-- Spring Security -->
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity4</artifactId>
        </dependency>
...

и все работало нормально. Затем я обновляю версию SpringBoot до

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

        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity4</artifactId>
            <version>3.0.4.RELEASE</version> 
        </dependency>
...

и я получил эту ошибку в 1 шаблоне:

Exception evaluating SpringEL expression: "#authorization.expression('hasRole(''ROLE_ADMIN'')')" (template: "tdk/common/menu" - line 87, col 21)

вот шаблон:

 <li th:if="${#authorization.expression('hasRole(''ROLE_ADMIN'')')}"    class="menu-principal pure-menu-item" th:classappend="${activeMenuItem == ‘tdkMessages'} ?  pure-menu-selected">
                    <a href=“/tdk/list" class="pure-menu-link">
                        <i class="fas fa-cloud-download-alt fa-lg fa-fw"></i>&nbsp; tdk
                    </a>
                </li>

1 Ответ

0 голосов
/ 01 ноября 2018

Thymeleaf теперь имеет специальное расширение / диалект для Spring Security 5. Вам нужно будет использовать его вместо Spring для 4.

<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>

Нужно сделать трюк, <version> управляется Spring Boot, так что вам не нужно его добавлять.

...