solution:Failed to update database "XXX.MDF" because the database is read-only.

本文解决了使用SQL Server 2005时遇到的“数据库为只读”错误。通过调整文件权限、设置用户权限及重启IIS服务,成功解决了网站无法更新数据库的问题。

As usual I did Build - Publish Web Site and then copied and pasted the published directory to my web server. When browsing any of the web pages that use the SQL Server 2005 database I get this error message: Failed to update database "XXX.MDF" because the database is read-only.

 

Solution:

This worked for me:
1) Make sure App_Data directory or any contained files does not have file system attribute Read-only set. (I had some files marked as Read-only)
2) Give user ASPNET and NETWORK SERVICE Modify control over the App_Data directory. (I had to add both these)
3) Run IISRESET to restart IIS to refresh its permissions.

 

and step 2 works here:

 after selecting "properties on the "App_Data" directory,

1.  Select the security tab

2. CLick on Add... under "Group or User names:" table

3. On the next window, select Advanced, another window appears and on this, select or rather click on "find now" and a list of Groups and Users should appear on the bottom table.

4.  Click on ASPNET followed by OK, and the same on the next 2 windows.

 

[ERROR] Some problems were encountered while processing the POMs: [FATAL] Non-resolvable parent POM for com.tplink.smb:solution-components-cache-ohc:2.0.0-SNAPSHOT: The following artifacts could not be resolved: com.tplink.smb:solution-components-cache:pom:2.0.0-SNAPSHOT (absent): Could not transfer artifact com.tplink.smb:solution-components-cache:pom:2.0.0-SNAPSHOT from/to cdd-nexus (https://nexus.crd.tp-link.com/repository/cdd-maven-public/): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target and 'parent.relativePath' points at wrong local POM @ line 5, column 13 @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project com.tplink.smb:solution-components-cache-ohc:2.0.0-SNAPSHOT (D:\tplearning_train_project\Ohcache_release\cache\solution-components-cache-ohc\pom.xml) has 1 error [ERROR] Non-resolvable parent POM for com.tplink.smb:solution-components-cache-ohc:2.0.0-SNAPSHOT: The following artifacts could not be resolved: com.tplink.smb:solution-components-cache:pom:2.0.0-SNAPSHOT (absent): Could not transfer artifact com.tplink.smb:solution-components-cache:pom:2.0.0-SNAPSHOT from/to cdd-nexus (https://nexus.crd.tp-link.com/repository/cdd-maven-public/): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target and 'parent.relativePath' points at wrong local POM @ line 5, column 13 -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
最新发布
10-28
<think>我们面对的问题是Maven构建时出现的两个主要错误:`Non-resolvable parent POM` 和 `PKIX path building failed`。结合引用内容,我们可以分析出: 1. PKIX错误通常是由于SSL证书验证失败引起的,即Maven无法验证远程仓库(如阿里云仓库)的SSL证书。 2. Non-resolvable parent POM错误则可能是因为无法下载父POM(如Spring Boot的starter-parent)导致,而无法下载的原因之一就是上面的证书问题。 因此,解决思路主要围绕如何让Maven信任远程仓库的SSL证书。以下是详细的解决步骤: ### 步骤1:获取远程仓库的SSL证书 我们需要从Maven仓库的URL获取SSL证书。以阿里云Maven仓库为例(https://maven.aliyun.com): 1. 使用浏览器访问 https://maven.aliyun.com,点击地址栏的锁图标,查看证书信息。 2. 导出证书为文件(通常为.crt格式)。具体操作因浏览器而异,但一般可以找到导出选项。 ### 步骤2:将证书导入到Java的信任库 Maven使用Java运行,因此需要将证书添加到Java的信任库(cacerts)中。 1. 找到你的Java安装目录(可以通过`java -version`和`which java`或`where java`找到路径)。假设Java安装路径为`$JAVA_HOME`,那么信任库通常在`$JAVA_HOME/lib/security/cacerts`。 2. 使用keytool工具导入证书: ```bash keytool -import -alias aliyun -keystore $JAVA_HOME/lib/security/cacerts -file /path/to/下载的证书.crt ``` 注意:默认的信任库密码是`changeit`。如果提示输入密码,请输入该密码。 3. 确认导入成功: ```bash keytool -list -keystore $JAVA_HOME/lib/security/cacerts -alias aliyun ``` ### 步骤3:检查Maven的settings.xml配置 确保Maven的settings.xml中正确配置了仓库镜像。例如,阿里云镜像的配置: ```xml <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>https://maven.aliyun.com/nexus/content/groups/public/</url> </mirror> ``` ### 步骤4:强制Maven更新本地仓库 有时候本地仓库中已经缓存了错误信息,需要清除缓存并强制更新: ```bash mvn clean install -U ``` 或者,如果知道是哪个依赖有问题,可以直接删除本地仓库中对应的目录(例如`~/.m2/repository/org/springframework/boot/spring-boot-starter-parent`),然后重新构建。 ### 步骤5:检查网络和代理设置 如果公司网络有代理,需要确保Maven的settings.xml中配置了正确的代理信息。 ### 步骤6:临时忽略SSL验证(不推荐,仅用于测试) 如果以上步骤都不能解决,可以尝试临时忽略SSL验证(注意:这会使连接不安全): 在Maven命令中加入以下参数: ```bash mvn -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true clean install ``` ### 总结 优先推荐使用步骤1和2解决证书信任问题。如果问题仍然存在,再考虑其他步骤。 §§相关问题§§ 1. 如何查看Java的安装路径? 2. Maven的settings.xml文件通常位于哪里? 3. 如何配置Maven使用阿里云镜像? 4. 为什么会出现PKIX path building failed错误? </think>### 解决Maven构建中的`Non-resolvable parent POM`和`PKIX path building failed`错误 该错误的根本原因是 **Maven无法验证远程仓库的SSL证书**(通常发生在使用阿里云镜像仓库时),导致无法下载父POM。以下是完整解决方案: --- #### 方法1:导入仓库SSL证书(推荐) 1. **下载仓库证书** 访问仓库域名(如阿里云仓库): ```bash openssl s_client -connect maven.aliyun.com:443 < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > aliyun.crt ``` 2. **导入证书到Java信任库** ```bash keytool -import -alias aliyun -keystore $JAVA_HOME/lib/security/cacerts -file aliyun.crt ``` * 默认密码:`changeit` * Windows路径示例:`C:\Program Files\Java\jdk1.8.0_301\jre\lib\security\cacerts` 3. **重启IDE或终端** 确保Java环境重新加载信任库。 --- #### 方法2:强制更新Maven缓存 ```bash mvn clean install -U -Dmaven.wagon.http.ssl.insecure=true ``` * `-U`:强制更新快照依赖 * `-Dmaven.wagon.http.ssl.insecure=true`:临时禁用SSL验证(仅限测试环境) --- #### 方法3:检查POM配置 1. **确认parent配置正确性** ```xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.5.RELEASE</version> <!-- 确保版本存在 --> </parent> ``` 2. **添加relativePath(本地仓库优先)** ```xml <parent> ... <relativePath/> <!-- 优先从本地仓库查找 --> </parent> ``` --- #### 方法4:重置Maven仓库缓存 1. 删除本地仓库中损坏的依赖: ```bash rm -rf ~/.m2/repository/org/springframework/boot/spring-boot-starter-parent/ ``` 2. 重新运行构建:`mvn clean install` --- #### 验证解决 成功构建后,控制台应显示: ``` [INFO] BUILD SUCCESS [INFO] Downloaded from alimaven: https://maven.aliyun.com/... (xx kB at xx kB/s) ``` > **根本原因**:Java信任库缺少仓库的CA证书[^1][^2]。阿里云镜像的SSL证书有时未被旧JDK版本信任,导入证书可永久解决[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值