I created an api domain with Spring Framework. Part 1

Isn't it fashionable if there is an API function?

I somehow wanted the one I made myself. It is an implementation method at once.

Allow Windows to connect to the subdomain of the local host.

First, before the development environment, prepare an environment where you can connect to the client → local server with a subdomain!

C:\Windows\System32\drivers\etc\hosts Edit Let's add "api.localhost".

# localhost name resolution is handled within DNS itself.
	127.0.0.1       localhost
	127.0.0.1       api.localhost
#	::1             localhost

Set the domain to subdomain in Tomcat.

Allows Tomcat to accept access on subdomains.

In C: \ Program Files \ Apache Software Foundation \ Tomcat 8.5 \ conf \ server.xml Let's add a host for the subdomain.

server.xml


      <Host name="api.localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>

This time, the API is delivered by the same application as the web application, so appBase is the default webapps.

Ready!

Now you are ready for delivery. From now on, I will actually write the Java code.

I created an api domain with Spring Framework. Part 2

Recommended Posts

I created an api domain with Spring Framework. Part 2
I created an api domain with Spring Framework. Part 1
I created an Atlassian-like web framework
I made a function to register images with API in Spring Framework. Part 1 (API edition)
I made a function to register images with API in Spring Framework. Part 2 (Client Edition)
Customize REST API error response with Spring Boot (Part 2)
Customize REST API error response with Spring Boot (Part 1)
Link API with Spring + Vue.js
Implement REST API with Spring Boot and JPA (domain layer)
Create an app with Spring Boot 2
REST API test with REST Assured Part 2
02. I made an API to connect to MySQL (MyBatis) from Spring Boot
I made a simple search form with Spring Boot + GitHub Search API.
Create an app with Spring Boot
I implemented Rails API with TDD by RSpec. part2 -user authentication-
I wanted to make JavaFX programming easier with the Spring Framework
I tried GraphQL with Spring Boot
I tried Flyway with Spring Boot
Test Spring framework controller with Junit
I made an eco server with scala
Spring Framework study notes [Part 1] DI container
Configure microservices with Spring Cloud (4): API Gateway
Downgrade an existing app created with rails 5.2.4 to 5.1.6
Create an RSA encryption-enabled JSON API with wicket
I made an API client for Nature Remo
I tried to link JavaFX and Spring Framework.
Get data with api created by curl command
I wanted to gradle spring boot with multi-project
◆ Get API created by Spring Boot from React
Create a web api server with spring boot
Handle JSON in cross domain with Play Framework