小编jay*_*g22的帖子

在spring boot app中禁用spring security

我有一个Spring Boot web应用程序,配置了spring security.我想暂时禁用身份验证(直到需要).

我把它添加到application.properties:

security.basic.enable: false   
management.security.enabled: false  
Run Code Online (Sandbox Code Playgroud)

这是我的一部分

但我仍然有一个基本的安全性:启动时生成一个默认的安全密码,我仍然收到HTTP身份验证提示框.

我的pom.xml:

<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>fr.test.sample</groupId>
    <artifactId>navigo</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <!-- Inherit defaults from Spring Boot -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.1.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.7</java.version>
        <jsoup.version>1.8.3</jsoup.version>
        <guava.version>18.0</guava.version>
        <postgresql.version>9.3-1103-jdbc41</postgresql.version>
    </properties>

    <!-- Add typical dependencies for a web application -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</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-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency> …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-boot spring-java-config

43
推荐指数
9
解决办法
9万
查看次数

JSTL关于enum的预告

我有一个使用枚举类型在java中声明的内容列表,它必须出现在jsp中.Java枚举声明:

public class ConstanteADMD {


    public enum LIST_TYPE_AFFICHAGE {
        QSDF("qsmldfkj"), POUR("azeproui");

        private final String name;

        @Override
        public String toString() {
            return name;
        }

        private LIST_TYPE_AFFICHAGE(String name) {
            this.name = name;
        }

        public static List<String> getNames() {
            List<String> list = new ArrayList<String>();
            for (LIST_TYPE_AFFICHAGE test : LIST_TYPE_AFFICHAGE.values()) {
                list.add(test.toString());
            }
            return list;
        }
    }
}


<select name="typeAffichage" id="typeAffichage">
    <c:forEach var="type" items="${netcsss.outils.ConstanteADMD.LIST_TYPE_AFFICHAGE.names}">
        <option value="${type}">${type}</option>
    </c:forEach>
</select>
Run Code Online (Sandbox Code Playgroud)

在哪里:

<select name="typeAffichage" id="typeAffichage">
    <c:choose>
        <c:when test="${catDecla ne null}">
            <option
                value="<%=catDecla.getCatDecla().getSTypeAffichage()%>"
                selected="selected"><%=catDecla.getCatDecla().getSTypeAffichage()%></option>
        </c:when>
    </c:choose> 
        <%List<String> list …
Run Code Online (Sandbox Code Playgroud)

java jsp enumeration jstl

10
推荐指数
3
解决办法
3万
查看次数

使用thymeleaf和springboot在标题中显示应用程序版本

我想在我的htm页面中显示我的webapp版本,使用类似的东西(百里香内部):

<h4 th:text="${version}">Version</h4>
Run Code Online (Sandbox Code Playgroud)

数据在pom.xml中设置得很好:

<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>fr.test.navig</groupId>
    <artifactId>navigo</artifactId>
    <version>2.0.3-SNAPSHOT</version>
...
<!-- Package as an executable jar -->
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>Application</mainClass>
                        <addDefaultImplementationEntries>
                            true
                        </addDefaultImplementationEntries>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

我可以在MANIFEST.MF(在META-INF下生成的jar中)中看到它:

实现 - 版本:2.0.3-SNAPSHOT

我试图在控制器中获取应用程序版本并将其设置在ModuleAttribute中:

@ModelAttribute("version")
public String getVersion() {
    logger.info("ModelAttribute to get application version");
    return getClass().getPackage().getImplementationVersion();
}
Run Code Online (Sandbox Code Playgroud)

getClass().getPackage().getImplementationVersion()价值是null.实际上,package implementationVersion默认情况下不是应用程序的实现版本.

maven spring-boot

5
推荐指数
2
解决办法
6656
查看次数

使用 java spring 中的 Post-Redirect-Get 模式转换 Post 请求

我想使用 post/redirect/get 模式转换 post 请求,以防止“为 HTTP 路径映射的模糊处理程序方法”错误。有关详细信息,请参阅此问题

这是初始代码:

@Controller
@RequestMapping("/bus/topologie")
public class TopologieController {
    private static final String VIEW_TOPOLOGIE = "topologie";

    @RequestMapping(method = RequestMethod.POST, params = { "genererCle" })
    public String genererCle(final Topologie topologie, final Model model)
        throws IOException {
        cadreService.genererCle(topologie);
        return VIEW_TOPOLOGIE;
    }
Run Code Online (Sandbox Code Playgroud)

我真的不明白如何使用 PRG 模式重新编码。即使我认为我理解基本概念。

java spring spring-mvc

4
推荐指数
1
解决办法
9117
查看次数

mvn -版本“mvn”无法识别

我已经使用 Windows 环境 IHM 在 Windows 7 上安装了 Maven:

\n\n
\n

M2_HOME : C:\\dev\\outils\\maven

\n
\n\n

\n\n
\n

路径:%JAVA_HOME\\bin;%M2_HOME\\bin;...

\n
\n\n

java -版本工作正常

\n\n
\n

java 版本“1.8.0_45”Java(TM) SE 运行时环境(内部版本\n 1.8.0_45-b15) Java HotSpot(TM) 64 位服务器 VM(内部版本 25.45-b02,混合模式)

\n
\n\n

但 mvn -version 不起作用:我得到的法语相当于:

\n\n
\n

\'mvn\' 未被识别为外部或内部命令,\n 可操作的程序或批处理文件

\n
\n\n

这是:

\n\n
\n

\'mvn\' n\'est pas reconnu en tant que commande interne or external, un\n program ex\xc3\xa9cutable or un fichier de commandes.

\n
\n\n

但 mvn 有效:

\n\n
\n

C:\\Users\\jerome>%M2_HOME%\\bin\\mvn …

windows maven

0
推荐指数
1
解决办法
1万
查看次数