maven\nginx配置文件

maven

settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<localRepository>C:\dev\mvn_repo</localRepository>
	<pluginGroups>	</pluginGroups>
	<proxies></proxies>
	<servers></servers>
	<mirrors>
		<mirror>  
			<id>aliyun</id>  
			<mirrorOf>central</mirrorOf>    
			<name>aliyun</name>  
			<url>https://maven.aliyun.com/repository/public</url>  
		</mirror>
	</mirrors>
	<profiles></profiles>
</settings>

gradle

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
 
buildscript {
    repositories { 
        // 添加阿里云 maven 地址         
        maven{ url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
 
allprojects {
    repositories {
        // 添加阿里云 maven 地址         
        maven{ url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/public' }
    }
}
 
task clean(type: Delete) {
    delete rootProject.buildDir
}

Eclipse

//lombok
-Xbootclasspath/a:lombok.jar
-javaagent:lombok.jar 

nginx

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    server {
        listen 80;
		server_name	localhost;
        location / {
            root   D:/front-demo;
            index  index.html index.htm;
        }
        location /api {
            proxy_pass http://localhost:8080/;
            proxy_set_header Host      $host;
        }
        location /aa {
            alias   D:/front-test/front-demo1;
            index  index.html index.htm;
        }
    }
}

Nginx服务器上配置内网下载Maven依赖,主要是为了让内部网络的机器能够通过代理访问Maven仓库,提高下载速度并管理流量。以下是一个基本的步骤: 1. **安装Nginx代理**: 首先确保Nginx已经在服务器上安装并运行。如果没有,你可以从官方网站下载适用于你的操作系统的版本。 2. **创建代理配置**: 编辑Nginx配置文件(通常是`/etc/nginx/nginx.conf` 或者 `/etc/nginx/sites-available/default`),添加一个新的location块来配置Maven代理。例如: ``` location /mvn-repo { proxy_pass http://your-mvn-proxy-server:8081; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_cache_bypass $http_upgrade; proxy_connect_timeout 90s; proxy_read_timeout 90s; proxy_send_timeout 90s; } ``` 这里假设你的Maven代理服务器监听的是8081端口,并且`your-mvn-proxy-server`是内网IP地址。 3. **启用代理**: 保存配置文件后,需要重启Nginx服务让新的配置生效: ``` sudo service nginx restart ``` 4. **配置客户端**: 对于使用命令行的开发者,可以在`.mavenrc`或`.mvnw`配置文件中设置代理: ``` MAVEN_OPTS="-Dhttp.proxyHost=your-mvn-proxy-server -Dhttp.proxyPort=8081" ``` 或者在`settings.xml`中加入如下部分: ```xml <proxies> <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <host>your-mvn-proxy-server</host> <port>8081</port> <nonProxyHosts>localhost|*.domain.com</nonProxyHosts> </proxy> </proxies> ``` 这里的`nonProxyHosts`可以指定不受代理影响的域名或IP。 5. **测试代理**: 现在你应该能够在本地通过Nginx代理来访问Maven仓库了。尝试运行`mvn dependency:resolve`看看是否能正常下载依赖。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值