Spring Tool Suite 在删除旧项目后不会在浏览器中显示新项目。

huangapple go评论63阅读模式
英文:

Spring Tool Suite doesn't show new project in browser after delete the old one

问题

I had an old project in STS, then I deleted it and created the new one with the same project name. I create controller class showed below:

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class MainController {

    @RequestMapping("/")
    public String index() {
        return "index";
    }

    @RequestMapping("login")
    public String login() {
        return "login";
    }
}

I have .html file also: index.html and login.html

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>INDEX</title>
</head>
<body>
    DANIEL---Index.
</body>
</html>

and

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>LOGIN</title>
</head>
<body>
    DANIEL---Login.
</body>
</html>

What I expect to be showed in the browser is just DANIEL---index and DANIEL---login, but in fact, it showed the content of the old project:

Spring Tool Suite 在删除旧项目后不会在浏览器中显示新项目。

Although I deleted the metadata folder and changed to another workplace, but it seems not to have any effect. Please help me.

I captured the STS screen:

Spring Tool Suite 在删除旧项目后不会在浏览器中显示新项目。
Spring Tool Suite 在删除旧项目后不会在浏览器中显示新项目。

英文:

I had an old project in STS, then I deleted it and created the new one with the same project name. I create controller class showed below:

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class MainController {

@RequestMapping(&quot;/&quot;)
public String index() {
	return &quot;index&quot;;
}

@RequestMapping(&quot;login&quot;)
public String login() {
	return &quot;login&quot;;
}
}

I have .html file also: index.html and login.html

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;ISO-8859-1&quot;&gt;
&lt;title&gt;INDEX&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    DANIEL---Index.
&lt;/body&gt;
&lt;/html&gt;

and

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;ISO-8859-1&quot;&gt;
&lt;title&gt;LOGIN&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    DANIEL---Login.
&lt;/body&gt;
&lt;/html&gt;

What I expect to be showed in browser is just DANIEL---index and DANIEL---login, but in fact, it showed the content of the old project:

Spring Tool Suite 在删除旧项目后不会在浏览器中显示新项目。

Although I deleted metadata folder and change to another workplace, but it seems not effect. Please help me.

I captured STS screen:
Spring Tool Suite 在删除旧项目后不会在浏览器中显示新项目。
Spring Tool Suite 在删除旧项目后不会在浏览器中显示新项目。

答案1

得分: 1

当您的类路径中存在spring-security时,它将自动设置重定向到登录页面,默认用户名为user,默认密码将在启动时打印在控制台上。

您可以在application.properties中指定不同的密码:
spring.security.user.password=password

当然,您也可以从pom文件中删除spring-security依赖,登录页面将被移除。

或者,您可以按照这里的说明进行设置:https://www.baeldung.com/spring-boot-security-autoconfiguration

英文:

When you have spring-security in your classpath it will automatically set up redirect to login with the default username being user and the default password will be printed in the console at the startup.

You can specify a different password in application.properties
spring.security.user.password=password

You can of course remove spring-security dependency from pom file and the login page will go away.

Or you can set it up like explained here https://www.baeldung.com/spring-boot-security-autoconfiguration

huangapple
  • 本文由 发表于 2020年8月1日 16:43:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/63203370.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定