问题描述
我尝试使用 spring 初始值设定项创建 Spring 启动应用程序。我刚刚使用依赖项创建了新应用
import React,{ useState } from "react";
import {
GoogleMap,InfoWindow,Marker,polyline
} from "@react-google-maps/api";
import scheduledOrders from "./data.json";
function Map() {
const [activeMarker,setActiveMarker] = useState(null);
let markers =
scheduledOrders !== undefined &&
scheduledOrders &&
scheduledOrders.map((item,index) => ({
id: index + 1,name: item.customerName + " - " + item.customerAddress,position: {
lat: Number(item && item.order_lat,10),lng: Number(item && item.order_lng,10)
}
}));
console.log("@@@markser",scheduledOrders);
const handleActiveMarker = marker => {
if (marker === activeMarker) {
return;
}
setActiveMarker(marker);
};
const handleOnLoad = map => {
const bounds = new window.google.maps.LatLngBounds();
markers && markers.forEach(({ position }) => bounds.extend(position));
map.fitBounds(bounds);
};
return (
<GoogleMap
onLoad={handleOnLoad}
onClick={() => setActiveMarker(null)}
mapContainerStyle={{ width: "100%",height: "88vh" }}
>
<polyline
path={
scheduledOrders !== undefined &&
scheduledOrders &&
scheduledOrders[0] &&
scheduledOrders.map(item => ({
lat: Number(item && item.order_lat,10)
}))
}
options={{
strokeColor: "#07966B",strokeOpacity: 1,strokeWeight: 2,icons: [
{
icon: "hello",offset: "0",repeat: "10px"
}
]
}}
/>
{/* The following Marker object will check if the index is the start or end */}
{markers &&
markers.map(({ id,name,position },i,arr) => {
if (i == 0 || i == arr.length)
return (
<Marker
key="start"
position={position}
onClick={() => handleActiveMarker("start")}
label={{ text: `START`,color: "black" }}
icon="http://maps.google.com/mapfiles/kml/shapes/arrow.png"
>
{activeMarker === "start" ? (
<InfoWindow onCloseClick={() => setActiveMarker(null)}>
<div>This is the start</div>
</InfoWindow>
) : null}
</Marker>
);
return (
<Marker
key={id}
position={position}
onClick={() => handleActiveMarker(id)}
label={{ text: `${id - 1}`,color: "white" }}
>
{activeMarker === id ? (
<InfoWindow onCloseClick={() => setActiveMarker(null)}>
<div>{name}</div>
</InfoWindow>
) : null}
</Marker>
);
})}
</GoogleMap>
);
}
export default Map;
但是当我尝试启动应用程序时它就会关闭。我已经创建了控制器并遵循了所有解决方案,例如:更改端口或从 .m2 文件夹中删除 tomcat 但没有任何效果。 这是我的日志
keep='last'
如果有人知道出了什么问题。 我使用的是 spring boot 2.4.5 版本。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
解决方法
似乎tomcat 嵌入的jar 没有包含在dependencies/jar 中。因为已经定义了“spring-boot-starter-web”依赖项,所以它应该是传递性的。但不知何故,它被排除在外。
尝试执行“mvn dependency:tree”并检查tomcat依赖是否存在并在“compile”范围内