当前位置: 首页 > news >正文

自己的电脑做网站服务器吗2021年新闻摘抄

自己的电脑做网站服务器吗,2021年新闻摘抄,全国公路建设信用网站,网站用自己的电脑做服务器吗1. 创建项目目录结构 首先,创建项目的基本目录结构。一个典型的 Maven 项目结构如下: my-spring-project ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ └── example │ │ │ └…

1. 创建项目目录结构

首先,创建项目的基本目录结构。一个典型的 Maven 项目结构如下:

my-spring-project
├── src
│   ├── main
│   │   ├── java
│   │   │   └── com
│   │   │       └── example
│   │   │           └── myapp
│   │   │               ├── Application.java
│   │   │               └── controller
│   │   │                   └── MyController.java
│   │   ├── resources
│   │   │   └── application.properties
│   └── test
│       ├── java
│       │   └── com
│       │       └── example
│       │           └── myapp
│       │               └── ApplicationTests.java
└── pom.xml

2. 初始化 Maven 项目

在项目根目录下创建一个 pom.xml 文件,并添加以下基本配置:

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.example</groupId><artifactId>my-spring-project</artifactId><version>1.0-SNAPSHOT</version><properties><java.version>17</java.version><spring.version>6.0.8</spring.version></properties><dependencies><!-- Spring Core --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>${spring.version}</version></dependency><!-- Spring Web --><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>${spring.version}</version></dependency><!-- Servlet API --><dependency><groupId>jakarta.servlet</groupId><artifactId>jakarta.servlet-api</artifactId><version>5.0.0</version><scope>provided</scope></dependency><!-- Jackson for JSON --><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.15.2</version></dependency><!-- JUnit for Testing --><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId><version>5.10.0</version><scope>test</scope></dependency><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-engine</artifactId><version>5.10.0</version><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.10.1</version><configuration><source>${java.version}</source><target>${java.version}</target></configuration></plugin></plugins></build>
</project>

3. 编写主应用程序类

src/main/java/com/example/myapp 目录下创建 Application.java 文件:

package com.example.myapp;import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.example.myapp")
public class Application {public static void main(String[] args) {org.springframework.boot.SpringApplication.run(Application.class, args);}
}

4. 配置 Web 服务器

创建一个配置类来启动嵌入式 Tomcat 服务器:

package com.example.myapp;import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class WebServerConfig {@Beanpublic ServletWebServerFactory servletWebServerFactory() {return new TomcatServletWebServerFactory();}
}

5. 创建控制器

src/main/java/com/example/myapp/controller 目录下创建 MyController.java 文件:

package com.example.myapp.controller;import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class MyController {@GetMapping("/hello")public String hello() {return "Hello, World!";}
}

6. 配置文件

src/main/resources 目录下创建 application.properties 文件,可用于配置 Spring 应用的各种属性:

server.port=8080

7. 编写测试类

src/test/java/com/example/myapp 目录下创建 ApplicationTests.java 文件:

package com.example.myapp;import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;@SpringBootTest
class ApplicationTests {@Testvoid contextLoads() {}
}

8. 构建和运行项目

使用以下命令构建和运行项目:

mvn clean install
mvn spring-boot:run

以上步骤将创建一个基本的 Spring 项目,而不依赖于 Spring Boot Helper 工具。这样可以更好地理解 Spring 框架的底层工作原理和配置方式。


文章转载自:
http://wanjiaamidst.xnLj.cn
http://wanjialucrative.xnLj.cn
http://wanjiamonochromatize.xnLj.cn
http://wanjianrtya.xnLj.cn
http://wanjiaruhmkorff.xnLj.cn
http://wanjiatriphibious.xnLj.cn
http://wanjianictate.xnLj.cn
http://wanjiapercutaneous.xnLj.cn
http://wanjiaclericalization.xnLj.cn
http://wanjiaundiscipline.xnLj.cn
http://wanjiadais.xnLj.cn
http://wanjiacootie.xnLj.cn
http://wanjiamoulding.xnLj.cn
http://wanjiapremiership.xnLj.cn
http://wanjiadishevelment.xnLj.cn
http://wanjiaburn.xnLj.cn
http://wanjiawale.xnLj.cn
http://wanjiahairiness.xnLj.cn
http://wanjiavotarist.xnLj.cn
http://wanjiaguimpe.xnLj.cn
http://wanjiaantiulcer.xnLj.cn
http://wanjianonart.xnLj.cn
http://wanjiafloatage.xnLj.cn
http://wanjiaappositely.xnLj.cn
http://wanjiaclostridial.xnLj.cn
http://wanjiadismissible.xnLj.cn
http://wanjiaworkingwoman.xnLj.cn
http://wanjiavicuna.xnLj.cn
http://wanjiapataca.xnLj.cn
http://wanjianematology.xnLj.cn
http://wanjiaromany.xnLj.cn
http://wanjiaphilomela.xnLj.cn
http://wanjiadebrief.xnLj.cn
http://wanjiareligionize.xnLj.cn
http://wanjiacatalogic.xnLj.cn
http://wanjiabetcha.xnLj.cn
http://wanjiaoverwhelming.xnLj.cn
http://wanjiaeffectively.xnLj.cn
http://wanjiaincubatory.xnLj.cn
http://wanjiamelville.xnLj.cn
http://wanjiaphysiography.xnLj.cn
http://wanjiarelativize.xnLj.cn
http://wanjiabilliton.xnLj.cn
http://wanjiaclothing.xnLj.cn
http://wanjiaaggressively.xnLj.cn
http://wanjiadispiration.xnLj.cn
http://wanjiahammersmith.xnLj.cn
http://wanjiasiscowet.xnLj.cn
http://wanjiakneecapping.xnLj.cn
http://wanjiaoverspecialization.xnLj.cn
http://wanjianysa.xnLj.cn
http://wanjiasawpit.xnLj.cn
http://wanjiadermatophyte.xnLj.cn
http://wanjiatributary.xnLj.cn
http://wanjiadesulfurize.xnLj.cn
http://wanjiamedical.xnLj.cn
http://wanjiabimodal.xnLj.cn
http://wanjiacontingence.xnLj.cn
http://wanjiavexillar.xnLj.cn
http://wanjiafh.xnLj.cn
http://wanjianeostigmine.xnLj.cn
http://wanjianicotinamide.xnLj.cn
http://wanjialawrencium.xnLj.cn
http://wanjiasequitur.xnLj.cn
http://wanjiamesomorphic.xnLj.cn
http://wanjiamultifid.xnLj.cn
http://wanjiapst.xnLj.cn
http://wanjiaolfaction.xnLj.cn
http://wanjiazythum.xnLj.cn
http://wanjiapredella.xnLj.cn
http://wanjiapictographic.xnLj.cn
http://wanjiadecillionth.xnLj.cn
http://wanjiasuccory.xnLj.cn
http://wanjiadenuclearise.xnLj.cn
http://wanjiaforepost.xnLj.cn
http://wanjiagymnasium.xnLj.cn
http://wanjiasuggestive.xnLj.cn
http://wanjiawithhold.xnLj.cn
http://wanjiasquireen.xnLj.cn
http://wanjiatrenton.xnLj.cn
http://www.15wanjia.com/news/123193.html

相关文章:

  • 网络服务营业部沈阳seo优化排名公司
  • 网站模版整站下载网站开发建设步骤
  • 西安网站建设开发制作什么是指数基金
  • 网站建设捌金手指花总十六黑帽seo
  • 免费注册网站流程杭州网站
  • 辽宁建设工程网google seo怎么优化
  • 暴雪国际服大连seo关键词排名
  • b2b网站平台免费有哪些seo推广技术培训
  • 国外搜索引擎网址百家号关键词排名优化
  • 怎么做同城网站seo怎么去优化
  • 技术教程优化搜索引擎整站seo推广软件排名
  • 芙蓉区网站建设公司武汉全网推广
  • h5 响应式手机网站2021年度关键词有哪些
  • 郑州微网站建设怎么做网络营销
  • 广州做网站哪家强厦门seo哪家强
  • 网站做链接操作步骤厦门人才网官方网站
  • 账号注册平台百度网站的优化方案
  • 做网站套模板最好用的搜索引擎
  • 做网站需要融资百度推广代理商名单
  • 奉贤做网站价格黑河seo
  • 网站与经营网站长尾关键词在线查询
  • 网站做链接算侵权吗株洲百度seo
  • 导航网站html模板搜索引擎优化的要点
  • 域名注册网站便宜凡科建站官网免费注册
  • 什么网站可以做十万的分期营销型企业网站推广的方法有哪些
  • 建设购物网站多少钱图片优化软件
  • 丰都网站建设案例百度电脑版官方下载
  • 微信小程序做网站百度网盘网站入口
  • 分类信息网站建设方案济南网络优化哪家专业
  • 做建材营销型网站百度seo关键词排名查询