Springboot开发非web(二)

建议使用方式一

package com.lgt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.lgt.serviceImpl.UserServiceImpl;

@SpringBootApplication
public class SpringProject2 implements CommandLineRunner{
	
	@Autowired
	private UserServiceImpl userService;
	
	@Override
	public void run(String... args) throws Exception {
		String sayHi = userService.sayHi("lgt");
		System.out.println(sayHi);
	}

	public static void main(String[] args) {
		SpringApplication.run(SpringProject2.class, args);
	}
}

可以看到方式一和二都没有启动tomcat

你可能感兴趣的:(springboot)