JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Web Framework » Spring web MVC  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 請教使用springboot 的schduleer 卻造成restful controller無法mapping
koall2k





發文: 41
積分: 0
於 2017-03-31 08:00 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
請教使用springboot 的schduler 卻造成MVC controller無法mapping

只要加上@ComponentScan(basePackages = "idv.matt.task") 所有MVC 都掛了
註解掉卻又好了
這兩個是否本來就會衝突
有甚麼方法可解呢

執行:http://localhost:8080/hello1 無法mapping

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Mar 31 15:55:07 CST 2017
There was an unexpected error (type=Not Found, status=404).
No message available


WebApplication.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.hellokoding.springboot;
 
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
 
@SpringBootApplication
@EnableScheduling
 
@ComponentScan(basePackages = "idv.matt.task") //只要加上這行 MVC Controller就掛了 
 
public class WebApplication   {
    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
    }
}
 


MyTask_001 .java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package idv.matt.task;
import java.util.Date;
 
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class MyTask_001 
{
private int count=0;
  @Scheduled(fixedRate = 5000)
  public void print(){
    System.out.println("hello - " + new Date().toString());
    }
 
  @Scheduled(fixedRate = 2500)
  public void print2(){
 
    System.out.println(count++);
 
    }
 
}


koall2k edited on 2017-03-31 08:02
reply to postreply to post
作者 Re:請教使用springboot 的schduleer 卻造成restful controller無法mapping [Re:koall2k]
jamestian





發文: 250
積分: 0
於 2017-04-02 08:42 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
看對你的問題有沒有幫助.

http://stackoverflow.com/questions/26794334/spring-boot-mvc-template-not-loading-404-not-found


reply to postreply to post
作者 Re:請教使用springboot 的schduleer 卻造成restful controller無法mapping [Re:jamestian]
koall2k





發文: 41
積分: 0
於 2017-04-05 07:14 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我將
@ComponentScan(basePackages = "idv.matt.task") //只要加上這行 MVC Controller就掛了
改成
@ComponentScan(basePackages = "task")

把packagename改掉 竟然好了 無法理解的問題點..


reply to postreply to post
» JWorld@TW »  Web Framework » Spring web MVC

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8