我在春季启动时使用此主要类提供了简单的登录应用程序:
package com.pai;
import com.pai.dao.userDao;
import com.pai.entity.User;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.crypto.password.PasswordEncoder;
@SpringBootApplication
public class ProjektpaiApplication {
@ Autowired
private userDao dao;
@ Autowired
private PasswordEncoder passwordEncoder;
public static void main ( String [] args ) {
SpringApplication . run ( ProjektpaiApplication . class , args ) ;
}
@PostConstruct
public void init ()
{
dao.save(new User("admin", "admin", "admin", passwordEncoder.encode("passwd")));
}
}
我想通过本教程中的CRUD应用程序连接该登录应用程序: https://www.youtube.com/watch?v=TcP5kFPq354 主类看起来像这样:
package com.pai;
import com.pai.domain.Post;
import com.pai.domain.PostRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ProjektpaiApplication2 implements CommandLineRunner {
@Autowired
private PostRepository repository;
public static void main(String[] args) {
SpringApplication.run(ProjektpaiApplication2.class, args);
}
@Override
public void run(String... strings) throws Exception {
for (int i = 0; i < 5; i++) {
repository.save(new Post("My post number #" + (i+1)));
}
}
}
如何连接它们以创建一个更大的应用程序,我可以同时执行这两个操作,登录然后使用CRUD函数?我试图将它们放在一个文件中,但它不起作用,当我将它们放在2个独立的文件中时,它也无法正常工作
答案 0 :(得分:0)
答案 1 :(得分:0)
您需要使用不同的端口,为此添加using (
(
from n in Observable.Interval(TimeSpan.FromSeconds(1.0), scheduler)
from g in Observable.FromAsync(() => GetItemsSource(), scheduler)
from u in Observable.FromAsync(() => DoSomethingAsync(g), scheduler)
select u)
.ObserveOn(scheduler)
.Subscribe())
{
Console.ReadLine();
};
中的属性server.port
:
application.properties