网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Spring项目运行怎么依赖spring-contex

小编这次要给大家分享的是Spring项目运行怎么依赖spring-contex,文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名与空间、网站空间、营销软件、网站建设、光山网站维护、网站推广。

spring项目跑起来,只需要spring-context这1个依赖项就行,参考下面:

一、pom.xml

<?xml version="1.0" encoding="UTF-8"?>

  4.0.0

  com.cnblogs.yjmyzz
  spring-boot-demo
  0.0.1-SNAPSHOT

  
    1.8
  

  
    
      org.springframework
      spring-context
      5.2.4.RELEASE
    
  

  
    
      
        maven-compiler-plugin
        3.1
        
          1.8
          1.8
        
      
    
  

二、示例代码:

package com.cnblogs.yjmyzz.springbootdemo;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;

/**
 * @author 菩提树下的杨过
 */
@ComponentScan("com.cnblogs.yjmyzz")
@Configuration
public class SampleApplication {

  interface SampleService {
    void helloWorld();
  }

  @Service
  class SampleServiceImpl implements SampleService {

    @Override
    public void helloWorld() {
      System.out.println("hello spring");
    }
  }

  public static void main(String[] args) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SampleApplication.class);
    SampleService service = context.getBean(SampleService.class);
    service.helloWorld();
  }
}

项目结构:

Spring项目运行怎么依赖spring-contex

spring-context的依赖关系如下:

Spring项目运行怎么依赖spring-contex

看完这篇关于Spring项目运行怎么依赖spring-contex的文章,如果觉得文章内容写得不错的话,可以把它分享出去给更多人看到。


文章名称:Spring项目运行怎么依赖spring-contex
当前路径:http://bjjierui.cn/article/pdcodg.html

其他资讯