在maven中引用github上的资源

很多人选择在Github上开源项目,但很多开源项目要依赖一些自己写的jar。如何让用户(使用者)可以通过互联网自动下载所依赖的jar呢?  下面介绍下通过GitHub做maven repository的过程;  1、在GitHub上创建项目(这步操作不细说了,过程很简单,用过GitHub的大家都懂的)  例如:我创建的项目名叫fengyunhe-wechat-mp 2、把本地maven项目Build,build生成的maven文件夹上传到Giuhub  3、本地新建maven项目如果需要依赖jar,在pom.xml中增加 
<repository>
    <id>fengyunhe</id>
    <name>fengyunhe</name>
    <url>https://raw.github.com/fengyunhe/fengyunhe-wechat-mp/master/</url>
</repository>
例如我的GitHub用户是fengyunhe那上面依赖仓库地址就是  https://raw.github.com/fengyunhe/fengyunhe-wechat-mp/master/ 备注:  1、上面的地址直接输入返回为404,页面是无法看到的  2、master 一定要写上,否则会无法下载  3、如果本地项目依赖的groupId、artifactId跟本地项目中的maven项目groupId、artifactId相对应,则会默认依赖本地项目而不去服务端下载。  4、具体依赖项目 配置中  groupId、artifactId 一定要与依赖项目的groupId、artifactId一致。
<groupId>com.fengyunhe</groupId>
<artifactId>fengyunhe-wechat-mp</artifactId>
<version>1.2.0-SNAPSHOT</version>

tips:

本文由wp2Blog导入,原文链接:http://devonios.com/maven-dependency-from-github.html

转载于:https://my.oschina.net/yangyan/blog/859289

要将Vue应用打包成jar,并在Spring Boot项目引用,您可以使用frontend-maven-plugin插件来执行这个任务。下面是一些步骤可以帮助您实现这个目标: 1. 在您的Vue项目根目录下创建一个`pom.xml`文件,并添加以下配置: ```xml <build> <plugins> <!-- frontend-maven-plugin配置 --> <plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>1.12.0</version> <executions> <!-- 安装 Node.js 和 NPM --> <execution> <id>install node and npm</id> <goals> <goal>install-node-and-npm</goal> </goals> <configuration> <nodeVersion>v14.17.3</nodeVersion> <npmVersion>6.14.13</npmVersion> </configuration> </execution> <!-- 安装 Vue 依赖 --> <execution> <id>npm install</id> <goals> <goal>npm</goal> </goals> <configuration> <arguments>install</arguments> </configuration> </execution> <!-- 执行 Vue 打包 --> <execution> <id>npm run build</id> <goals> <goal>npm</goal> </goals> <configuration> <arguments>run build</arguments> </configuration> </execution> </executions> </plugin> </plugins> </build> ``` 请注意,您需要根据您的项目需求调整`nodeVersion`和`npmVersion`的版本号。 2. 打开终端并导航到您的Vue项目根目录,运行以下命令将Vue应用打包: ```shell mvn clean install ``` 这个命令将触发frontend-maven-plugin插件的执行,它将安装Node.js和NPM,安装Vue依赖,并执行Vue打包。 3. 打包成功后,您将在`target`目录下找到生成的jar文件。将该jar文件复制到您的Spring Boot项目,并将其作为依赖添加到Spring Boot项目的`pom.xml`文件。 ```xml <dependency> <groupId>your.groupId</groupId> <artifactId>your-artifactId</artifactId> <version>your-version</version> <scope>runtime</scope> </dependency> ``` 请记得将`your.groupId`、`your-artifactId`和`your-version`替换为您实际的值。 4. 在Spring Boot项目,您可以使用`org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration`类的`addResourceHandlers()`方法来配置静态资源的处理。添加以下代码: ```java @Configuration public class WebConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/static/**") .addResourceLocations("classpath:/static/") .setCachePeriod(0); } } ``` 这将使Spring Boot能够正确地处理静态资源路径。 现在,您可以重新构建并运行Spring Boot项目,Vue应用将作为静态资源打包在jar,并能够在Spring Boot应用访问。 请注意,这只是一种将Vue应用打包成jar并在Spring Boot项目引用的方法。根据您的具体需求和项目结构,可能需要进行一些调整和修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值