springboot打包jar包找不到jsp文件以及在linux永久执行java -jar以及springboot的多环境配置

因为springboot打包jar包执行jsp和在linux永久执行java -jar以及springboot的多环境配置 都是springboot的 就放在一起说了  

先说 打包jar 不能找到jsp问题:

打包成jar的时候会找不到jsp文件  只需要 在pom.xml文件添加

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<configuration>
					<encoding>UTF-8</encoding>
					<useDefaultDelimiters>true</useDefaultDelimiters>
				</configuration>
			</plugin>
		</plugins>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
			</resource>
			<resource>
				<directory>src/main/webapp</directory>
				 <!--注意此次必须要放在此目录下才能被访问到 -->
		         <targetPath>META-INF/resources</targetPath>
		         <includes>
		            <include>**/**</include>
		         </includes>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
				<filtering>true</filtering>
			</testResource>
		</testResources>
	</build>


 

然后打包使用命令  mvn package

然后启动jar  使用 java -jar app.jar      

在此也说一下spring 的多环境配置:

在pom.xml文件添加:

	<profiles>
		<profile>
			<id>dev</id>
			<properties>
				<profiles.active>dev</profiles.active>
				<maven.test.skip>true</maven.test.skip>
				<scope.jar>compile</scope.jar>
			</properties>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
		</profile>
		<profile>
			<id>test</id>
			<properties>
				<profiles.active>test</profiles.active>
				<maven.test.skip>true</maven.test.skip>
				<scope.jar>provided</scope.jar>
			</properties>
		</profile>
		<profile>
			<id>prod</id>
			<properties>
				<profiles.active>prod</profiles.active>
				<maven.test.skip>true</maven.test.skip>
				<scope.jar>provided</scope.jar>
			</properties>
		</profile>
	</profiles>

然后就可以把springboot的配置文件分成 开发用 测试用 生产环境用的xml或yml

在打包时候 使用  java -jar app.jar --spring.profiles.active=dev  这样就能指定开发环境springboot的配置文件

如果在liunx上启动jar包 使用传统的java -jar会导致 操作之后就会关闭这个程序 

所以可以使用:nohup java -jar app.jar --spring.profiles.active=dev & 来启动这个程序  当然要关闭这个启动程序 需查看端口号 

使用:ps aux|grep java 来查看java运行的端口 最后使用 kill 1020来杀掉这个端口  这里的 1020 是一个比如的端口号

因为比较急,写的可能有些粗糙 如果有问题 可以留言,一起讨论。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xxpr_ybgg

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值