• SpringBoot项目登陆页面


    前面都是自动生成的

     

     自动联网生成后会自动下载相关依赖

    题外话一句:刚用idea不久,发现新项目每次都要设置下maven,贼烦,怎么破?

     新建一个control

    1 @RestController
    2 public class helloControl {
    3     @GetMapping("/hello")
    4     public String hello(){
    5         return "hello SpringBoot";
    6     }
    7 }

    运行main方法

     http://localhost:8080/hello

    到此还没有结束~~~

    在特么templates下新建login.html页面

    Controller内接口注解调整,防止只会返回字符串
    @Controller
    public class helloControl {
        @GetMapping("/hello")
        @ResponseBody
        public String hello(){
            return "hello SpringBoot";
        }
    
        @GetMapping("/login")
        public String login(){
            return "login";
        }
    }

    启动,o78k,报错了

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project springbootdeme: Input length = 1 -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

    定位,联网自动生成的pom文件里maven版本过高,降级

    <plugins>
                <!--<plugin>这个版本太高了
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>-->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.7</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.maven.shared</groupId>
                            <artifactId>maven-filtering</artifactId>
                            <version>1.3</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>

    修改过可以正常启动了。开始访问http://localhost:8080/login

    o78k,报错了, 罚克~~~过完年再看

    javax.servlet.ServletException: Circular view path [login]: would dispatch back to the current handler URL [/login] again. 
    Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.) at org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:210) ~[spring-webmvc-5.3.3.jar:5.3.3] at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:148) ~[spring-webmvc-5.3.3.jar:5.3.3] at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316) ~[spring-webmvc-5.3.3.jar:5.3.3]、

     ok,家人看春晚,我在搞代码,代码都删除,重新搞一个

    启动,竟然好了,真是神奇~~~~

    可是,这是为什么呢??

  • 相关阅读:
    Codeforces Gym 100571A A. Cursed Query 离线
    codeforces Gym 100500 J. Bye Bye Russia
    codeforces Gym 100500H H. ICPC Quest 水题
    codeforces Gym 100500H A. Potion of Immortality 简单DP
    Codeforces Gym 100500F Problem F. Door Lock 二分
    codeforces Gym 100500C D.Hall of Fame 排序
    spring data jpa 创建方法名进行简单查询
    Spring集成JPA提示Not an managed type
    hibernate配置文件中的catalog属性
    SonarLint插件的安装与使用
  • 原文地址:https://www.cnblogs.com/52czm/p/14395698.html
Copyright © 2020-2023  润新知